andreizanik / cookies-next

Getting, setting and removing cookies on both client and server with next.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not assignable to type OptionType in Next 12.2.0

mastepanoski opened this issue · comments

I upgraded to next 12.2.0, and then started getting this error:

Type 'IncomingMessage & { cookies: Partial<{ [key: string]: string; }>; }' is not assignable to type '(IncomingMessage & { cookies?: { [key: string]: string; } | undefined; }) | undefined'.
  Type 'IncomingMessage & { cookies: Partial<{ [key: string]: string; }>; }' is not assignable to type 'IncomingMessage & { cookies?: { [key: string]: string; } | undefined; }'.
    Type 'IncomingMessage & { cookies: Partial<{ [key: string]: string; }>; }' is not assignable to type '{ cookies?: { [key: string]: string; } | undefined; }'.
      Types of property 'cookies' are incompatible.
        Type 'Partial<{ [key: string]: string; }>' is not assignable to type '{ [key: string]: string; }'.
          'string' index signatures are incompatible.
            Type 'string | undefined' is not assignable to type 'string'.
              Type 'undefined' is not assignable to type 'string'.

20         req: ctx.req,

So if I change OptionType declaration like this, it works:

export interface OptionsType extends CookieSerializeOptions {
  res?: ServerResponse
  req?: IncomingMessage & {
    cookies?: Partial<{ [key: string]: string }>
  }
}

Thanks!
I know about this problem and there is an open pull request #19

There will be a new version of the package with a fix for this problem in the near future

Please update package version to 2.1.0