serverless-express
serverless-express copied to clipboard
Type error with Koa
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'.
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.
Or perhaps the alter-ego @brett-vendia is the right one to tag
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.