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
Underlying HttpServer is of type any
#10480
Comments
Let's use the nest/packages/platform-express/adapters/express-adapter.ts Lines 186 to 193 in 21bd8c3
nest/packages/platform-express/adapters/express-adapter.ts Lines 118 to 119 in 21bd8c3
as you can see above, we can't define the right return type statically for the return of What we could do is narrow down that a bit. That method could then have the following return type instead of |
nvm lol I just found that the
both of them points to server.listen method from So we could replace that |
Let's track this here #10481 |
Great! do we want to make the same adjustment in other places as well? (e.g. fastify) |
I thought that the nest/packages/platform-fastify/adapters/fastify-adapter.ts Lines 222 to 228 in 60d286d
but I just tested it and it returns the same Server instance. I'll update that too then. |
I'm getting
|
Well, as you've stated yourself, the actual object is different from the type definition, it makes sense that you get a type error. Using the |
yeah, I need to figure out why the type of |
Is there an existing issue for this?
Current behavior
app.listen()
andapp.getHttpServer()
return the underlying HttpServer, but regarding types - the returned type isany
.Is there a way we can improve this type?
Currently, I'm doing this, which feels unsafe:
Minimum reproduction code
https://codesandbox.io/s/ecstatic-sanderson-xpxxfv
Steps to reproduce
server
const.any
Expected behavior
I expect server to have a safer type, perhaps
{ Server } from 'https'
?maybe something else? Open for suggestions
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
8.0.6
Packages versions
Node.js version
16.14.0
In which operating systems have you tested?
Other
Relevant source code block:
nest/packages/common/interfaces/nest-application.interface.ts
Line 57 in 21bd8c3
The text was updated successfully, but these errors were encountered: