Skip to content
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

MiddlewareFunction interface is missing parameter type information #778

Closed
bschlenk opened this issue Jun 11, 2018 · 4 comments
Closed

MiddlewareFunction interface is missing parameter type information #778

bschlenk opened this issue Jun 11, 2018 · 4 comments

Comments

@bschlenk
Copy link

I'm submitting a...


[ x ] Feature request
[ x ] Documentation issue or request

Current behavior

The MiddlewareFunction interface doesn't contain type information for the parameters:

export type MiddlewareFunction = (req?, res?, next?) => any;

Expected behavior

The params of MiddlwareFunction to be stongly typed, something like:

export type MiddlewareFunction = (req?: ExpressRequest, res?: ExpressResponse, next?: ExpressNext) => any

What is the motivation / use case for changing the behavior?

I'm not sure what I can expect from these parameters without type information. Is there a reason for them all to explicitly be any? If it's because Nest isn't tied to a specific framework, then perhaps there could be separate ExpressMiddlewareFunction, KoaMiddlewareFunction, etc.?

If there is a simple way for me to annotate the middleware function myself I can do that, but it would be cool if the MiddlewareFunction was already annotated.

Environment


Nest version: 5.0.1

 
For Tooling issues:
- Node version: 10.3.0  
- Platform:  Mac
@eliasjnior
Copy link

For what I now, we can use Fastify. So Express "names" wouldn't work. Not sure :P

@kamilmysliwiec
Copy link
Member

@eliasjnior exactly. Maybe instead of leaving them as any, we could make this interface generic. TBC

@kamilmysliwiec
Copy link
Member

Added in 5.1.0 release

@lock
Copy link

lock bot commented Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants