[types] invalid HttpRoute typing
xobotyi opened this issue ยท 3 comments
Bug Report
Is you/your team sponsoring this project
- Yes
- No
Minimal reproducible repo
https://codesandbox.io/s/clever-shirley-dy0l5?file=/src/index.ts
Current Behavior
Getting error:
error TS2769: No overload matches this call.
Overload 1 of 4, '(path: string, callback: HttpRoute): nanoexpressApp', gave the following error.
Argument of type '(req: HttpRequest, res: HttpResponse) => HttpResponse' is not assignable to parameter of type 'HttpRoute'.
Type 'HttpResponse' is missing the following properties from type 'nanoexpressApp': connect, host, port, address, and 19 more.
Overload 2 of 4, '(path: string, ...middlewares: MiddlewareRoute[]): nanoexpressApp', gave the following error.
Argument of type '(req: HttpRequest, res: HttpResponse) => HttpResponse' is not assignable to parameter of type 'MiddlewareRoute'.
Type 'HttpResponse' is not assignable to type 'nanoexpressApp'.
Overload 3 of 4, '(path: string, options: RouteOption, ...middlewares: MiddlewareRoute[]): nanoexpressApp', gave the following error.
Type '(req: HttpRequest, res: HttpResponse) => HttpResponse' has no properties in common with type 'RouteOption'.
Expected behavior/code
TO have proper type definitions =)
Environment
- Node/npm version: node 15.11, yarn 1.22.10, npm 7.6.0
- OS: Windows 10
- Addinational Info:
Possible Solution
If to assume that docs are right, HttpRoute
type definition should be like this:
type HttpRoute = (req: HttpRequest, res: HttpResponse) => any | Promise<any>;
Hi @xobotyi.
Thanks for trying out my library. PR is welcome and would be great.
I do at end of month some changes as well as try refactor entire code-base for more stable performance
@dalisoft maybe you're looking forward using TS as a language?
i'd be happy to help with moving codebase to TS and/or maybe to maintain framewok. Because performance is outstanding according to https://github.com/the-benchmarker/web-frameworks and thats what i'm exactly looked for a while (also wanted to start something my own =)).
The release is available on:
Your semantic-release bot