serverless-express icon indicating copy to clipboard operation
serverless-express copied to clipboard

Type error with Koa

Open jimmone opened this issue 4 years ago • 3 comments

I get the following TypeScript error when building using Koa version 2.13.4 and @vendia/serverless-express version 4.5.2:

server/index.ts(10,51): error TS2322: Type 'import("/path/to/project/node_modules/@types/koa/index.d.ts")<DefaultState, DefaultContext>' is not assignable to type 'RequestListener'.
--
80 | Type 'import("/path/to/project/node_modules/@types/koa/index.d.ts")<DefaultState, DefaultContext>' provides no match for the signature '(req: IncomingMessage, res: ServerResponse): void'.

jimmone avatar Jan 20 '22 16:01 jimmone

Confirmed. Seeing this as well. @brettstack can we get eyeballs on this one - looks like it's been around the better part of a year.

shellscape avatar Jul 26 '22 16:07 shellscape

Or perhaps the alter-ego @brett-vendia is the right one to tag

shellscape avatar Jul 26 '22 16:07 shellscape

What worked for me is calling app.callback() https://koajs.com/#app-callback- which returns a function suitable for using with mounting express-like servers.

serverlessExpress({ app: app.callback() });

The examples could probably benefit from an update.

saveman71 avatar Jan 09 '23 14:01 saveman71