timostamm / protobuf-ts

Protobuf and RPC for TypeScript
Apache License 2.0
1.07k stars 127 forks source link

Request: Support for moduleResolution "nodenext" and "node16" #644

Closed SanjoSolutions closed 5 months ago

SanjoSolutions commented 5 months ago

The moduleResolution settings "nodenext" and "node16" require import paths with file extensions. Right now the import paths in the generated TypeScript code have no file extensions. This gives me the error "Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. [..] ts(2835)".

SanjoSolutions commented 5 months ago

As a workaround I'm running now sed -Ei 's/(import .* from "\.\/.+)(")/\1.js\2/g' src/protos/*.ts after generating the TypeScript, which adds the ".js" extensions.

timostamm commented 5 months ago

Duplicate of https://github.com/timostamm/protobuf-ts/issues/182