You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rootDirs with Node16/NodeNext removes import extensions on file rename #50725
Create a tsconfig.json setting moduleResolution to "Node16" and rootDirs to ["src"].
Create src/a.ts and src/b.ts.
Import './b.js' in src/a.ts.
Try renaming src/b.ts. (Make sure to enable automatic import updating in your editor)
🙁 Actual behavior
TypeScript updates the filename, removing the extension as a result. In ESM this would then err that “File may not be imported without an extension”. (Also, it seems that typescript.preferences.importModuleSpecifierEnding is ignored.)
🙂 Expected behavior
The file extension should not be removed by TypeScript since the original import had it.
changed the title [-]`rootDirs` with `Node16`/`NodeNext` removes extensions on file rename[/-][+]`rootDirs` with `Node16`/`NodeNext` removes import extensions on file rename[/+]on Sep 12, 2022
Activity
[-]`rootDirs` with `Node16`/`NodeNext` removes extensions on file rename[/-][+]`rootDirs` with `Node16`/`NodeNext` removes import extensions on file rename[/+]andrewbranch commentedon Sep 12, 2022
Related and possibly the same code path: #50710
Thanks for the fourslash test! ❤️
(fix #50725, #50710) add file extensions in import statements (#51702)