-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signature Mismatch in MiddlewareInterface
#21
Comments
Not sure what is possible there. I know about this issue with typescript, one solution can be if we create two separate interfaces |
If I can work out a way to keep it all in one interface, I'll let you know. I'll take another look and maybe check if anyone on StackOverlow has any ideas. |
@JD-Robbs I was able to get it to compile by overloading the method on my custom class with a more generic signature: @Middleware()
export class CustomerHeader implements MiddlewareInterface {
use(request: any, response: any, next?: (err?: any) => any): any;
use(request: Request, response: Response, next?: NextFunction): any {
// ...
next();
}
} @pleerock I think if you annotate |
new middleware interface signatures are being added in #119 |
middlewares now have separate signatures in 0.7.0 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Consider the following code (note the Request/Response type hints):
Compiling throws the following error:
This, however, works:
I tracked the issue to the second (Koa) signature in
MiddlewareInterface
(removing it fixes the above but, obviously, won't make Koa happy). It looks like my code makes the TypeScript compiler think I'm trying to implement the second signature.While I tried changing/adding signatures in
MiddlewareInterface
, I couldn't get it to compile.The text was updated successfully, but these errors were encountered: