-
Notifications
You must be signed in to change notification settings - Fork 651
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
Avoid unused definition imports from proto-loader #1826
Avoid unused definition imports from proto-loader #1826
Conversation
|
Since proto files don't always contain all types of definition, it was possible to get into a state where generated code contained unused imports which caused TS errors. This change makes those imports conditional on the existence of the corresponding definitions in the proto file. Co-authored-by: Austin Puri <austin.puri@gmail.com> Co-authored-by: Joe Porpeglia <josephp@spotify.com> Signed-off-by: Mike Lewis <mtlewis@users.noreply.github.com>
71d08ba
to
f289c34
Compare
@@ -617,7 +645,7 @@ function generateLoadedDefinitionTypes(formatter: TextFormatter, namespace: Prot | |||
|
|||
function generateRootFile(formatter: TextFormatter, root: Protobuf.Root, options: GeneratorOptions) { | |||
formatter.writeLine(`import type * as grpc from '${options.grpcLib}';`); | |||
formatter.writeLine("import type { ServiceDefinition, EnumTypeDefinition, MessageTypeDefinition } from '@grpc/proto-loader';"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the ServiceDefinition
import in the old version of the line appears to always be unused in the generated code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I think it became unused in #1745.
The change looks good. Please run |
Signed-off-by: Mike Lewis <mtlewis@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution
This has been published in version 0.6.3. |
Since proto files don't always contain enums and messages, it was possible to get into a state where generated code contained unused imports which caused TS errors. This change makes those imports conditional on the existence of the corresponding definitions in the proto file.
Co-authored-by: Austin Puri austin.puri@gmail.com
Co-authored-by: Joe Porpeglia josephp@spotify.com