Closed jbl428 closed 1 year ago
Would you like to create a PR for this issue?
Yes, I would like to work on it. :)
@kamilmysliwiec
I would like to hear opinions before creating a pull request.
While reviewing the code, I discovered that resolving this issue requires moving the Transport.enum.ts
, microservice-configuration.interface.ts
, and other related interfaces from @nestjs/microservice
to @nestjs/common
.
In the Git history, these files were previously located in @nestjs/common
but were removed in this commit e8da23cd
Hence, moving them back is not a ideal option.
An alternative solution could be to create new interface files specifically for the server in the @nestjs/common
package. However, this may result in duplicated code, as the Transport enum would be duplicated.
Another option is to simply update the documentation to guide users in using the correct type of interface. what do you think?
Another option is to simply update the documentation to guide users in using the correct type of interface.
Sounds good @jbl428!
I have discovered that type inference works correctly when providing the MicroserviceOptions
type in the createMicroservice
method.
I suspect that the issue was due to a temporary problem with my IDE causing it not to function properly.
Therefore, it seems appropriate to close this issue. π
Instead, there are some test codes where the generic type is not provided and incorrect options are used. so, I will create a pull request to address this issue.
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
When using
connectMicroservice
andcreateMicroservice
from@nest/microservice
, we must explicitly provide theoptions type
for type safety.In contrast, the
register
method fromClientsModule
has convenient type inference based on the specified Transport.Describe the solution you'd like
It would be great if
connectMicroservice
could also provide convenient type inference using the type declaration ofClientsModule
, if possible.If this is not feasible, I suggest updating the documentation in each microservice section.
ex) Grpc docs
Teachability, documentation, adoption, migration strategy
connectMicroservice
andcreateMicroservice
What is the motivation / use case for changing the behavior?
In the Nest.js documentation, there is an example on how to create a gRPC server.
https://docs.nestjs.com/microservices/grpc
Although it uses
MicroserviceOptions
as the generic type, this does not allow for auto-completion or type inference for gRPC options.