cookies-next
cookies-next copied to clipboard
`req` and `res` types are not compatible
I can't pass req
as param, why is that?
export const someFunction = (
req: NonNullable<Parameters<typeof getCookie>[1]>['req'],
) => {
return getCookie('key', { req }); // req ts error
}
Type '(IncomingMessage & { cookies?: TmpCookiesObj | undefined; }) | Request | NextRequest | undefined' is not assignable to type 'Request | NextRequest | undefined'.
Type 'IncomingMessage & { cookies?: TmpCookiesObj | undefined; }' is not assignable to type 'Request | NextRequest | undefined'.
Type 'IncomingMessage & { cookies?: TmpCookiesObj | undefined; }' is missing the following properties from type 'NextRequest': geo, ip, nextUrl, page, and 20 more.ts(2322)
Using req: OptionsType['req'],
gives me exactly the same error
Facing the same issue. Declaring and passing NonNullable<Parameters<typeof getCookie>[1]>
would work, though, but that's not the same.