-
Notifications
You must be signed in to change notification settings - Fork 660
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
[Feature Request]: proto-loader-gen-types
: More options for generated code
#2907
Comments
When I initially created that tool, I had it generate As you can see in #2693, we tried adding the file extension and it broke in some cases. I am OK with adding an option, but first I would really like to understand whether there is an extension that we can always set, and if not, why not. |
|
That seems reasonable. I would be OK with adding those options. |
Hi, I encountered the same issue and would like to submit a PR to fix it. Here are my ideas: Add the following two options to
The default behavior of Any suggestions? |
Is your feature request related to a problem? Please describe.
After extensive trial and error, I found that
proto-loader-gen-types
is the simplest solution for generating type definitions for code that uses@grpc/grpc-js
in TypeScript.But the TypeScript code generated by
proto-loader-gen-types
has the following issues:.ts
, but since it is meant for type declarations, it is supposed to be.d.ts
instead.module": "nodenext"
set intsconfig.json
and"type": "module"
set inpackage.json
for Node projects, VS Code raises warnings about missing file extensions in import module specifiers. When using ESM in Node, both Node.js and TypeScript's module resolution require explicit file extensions in import paths. However, the code generated byproto-loader-gen-types
does not automatically include them. This results in a manual update step after code generation, which is inconvenient and an antipattern.Describe the solution you'd like
.ts
or.d.ts
) is used for generated code. Maybe something like thisAdditional context
There are related discussions, such as #2693 and #2401. This issue aims to revive the topic and encourage further discussion.
The text was updated successfully, but these errors were encountered: