hoangvvo / next-connect

The TypeScript-ready, minimal router and middleware layer for Next.js, Micro, Vercel, or Node.js http/http2
https://www.npmjs.com/package/next-connect
MIT License
1.64k stars 65 forks source link

Typescript errors when used in /pages #68

Closed coderunderatree closed 4 years ago

coderunderatree commented 4 years ago

I'm getting the below typescript error when I use handler.apply method inside pages

Argument of type 'IncomingMessage' is not assignable to parameter of type 'NextApiRequest'.
  Type 'IncomingMessage' is missing the following properties from type '{ query: { [key: string]: string | string[]; }; cookies: { [key: string]: string; }; body: any; }': query, cookies, body

So, inside the getServerSideProps/getInitialProps method the req and res we get from context are of type Incoming message and ServerResponse respectively and I'm not able to run the handler because of this issue

hoangvvo commented 4 years ago

I just changed the types to IncomingMessage and ServerResponse in 0.7.2

coderunderatree commented 4 years ago

Yes it works now thanks!