-
Notifications
You must be signed in to change notification settings - Fork 687
Closed
Description
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:
- The file extension is
.ts, but since it is meant for type declarations, it is supposed to be.d.tsinstead. - With
module": "nodenext"set intsconfig.jsonand"type": "module"set inpackage.jsonfor 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-typesdoes 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
- Provide an option to configure which file extension (
.tsor.d.ts) is used for generated code. Maybe something like this - Provide an option to configure whether file extensions are appended to module specifiers in generated code. Maybe something like this
Additional context
There are related discussions, such as #2693 and #2401. This issue aims to revive the topic and encourage further discussion.
Metadata
Metadata
Assignees
Labels
No labels