cookies-next icon indicating copy to clipboard operation
cookies-next copied to clipboard

`req` and `res` types are not compatible

Open mateuszpigula opened this issue 1 year ago • 1 comments

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

mateuszpigula avatar Jan 10 '24 09:01 mateuszpigula

Facing the same issue. Declaring and passing NonNullable<Parameters<typeof getCookie>[1]> would work, though, but that's not the same.

JonasDoe avatar Jul 10 '24 08:07 JonasDoe