Add file extensions to generated imports.
See original GitHub issueFiles generated by the protoc plugin, currently, import witht he following syntax import {x} from 'y'
however for reasons outlined in https://github.com/nodejs/modules/issues/444, the following syntax should be used for forward compatibility with esmodules import {x} from 'y.js'
Further reading: https://nodejs.org/api/esm.html#import-specifiers https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Appending .js extension on relative import statements during ...
For new files, it is possible to simply add ".js" extension in the import statement in Typescript file while editing. Example: import { ......
Read more >Provide a way to add the '.js' file extension to the end ... - GitHub
TypeScript transpiles to JS but then generates broken (modern) JS code. Just add the option already to generate the ".js" extension for imports...
Read more >Automatically add file extensions in imports in files with .mjs ...
Automatically add file extensions in imports in files with .mjs extension. 1.
Read more >add-js-extension - npm
It appends the .js file extensions to the import statements in the JavaScript files that are generated by TypeScript when it is necessary....
Read more >Documentation - Module Resolution - TypeScript
To accomplish this, TypeScript overlays the TypeScript source file extensions ( .ts , .tsx , and .d.ts ) over Node's resolution logic. TypeScript...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
#233
There is also the deprecated
packages/plugin-framework/src/typescript-import-manager.ts
, which can be ignored - it is not used anymore.There is a spec file for parts of
typescript-imports.ts
. It is probably best to extend the test coverage a bit (its not actually coveringTypeScriptImports
yet) and implement against it.I don’t think it will be feasible to add test coverage in
@protobuf-ts/plugin
, because if I’m not mistaken, it uses a TypeScript version that does not support the.js
imports yet.