-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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: disable extensionless imports #28288
Comments
Related: https://github.com/Microsoft/vscode/issues/62401 This one is specifically about treating extension-less imports as an error, presumably when you are using |
I added a |
I’m going to put my support behind seeing a fix for this. Browsers support ES modules natively now and TS isn’t a nice experience for web development because:
...which creates a perfect storm in which it’s possible to write several modules with a nontrivial dependency graph before realizing that the whole thing is broken because none of the import statements have extensions. Fixing it is then an exercise in patience as you hunt through the project looking for offending imports—and the browser won’t help you here because it stops short at the first one that fails to load. It’s not a good development experience, which sucks because TS is so, so nice otherwise. :( Even if TS just rewrote imports in the generated code to append a |
I had the same problem and until the compiler has this option to add Here is the plugin if anyone has interest in it: https://www.npmjs.com/package/babel-plugin-add-import-extension |
@karlprieb See https://github.com/Zoltu/typescript-transformer-append-js-extension/ for a TypeScript transformer that adds |
@MicahZoltu Thank you, Great work! |
It's weird but I don't think this issue has any links yet to the ur-issue, #16577. Technically, providing a flag to error out is different from providing a flag to append the correct extension, but it's pretty similar. |
This is |
I'd like there to be a way to always require the file extension to be specified for relative import statements. At the moment extensionless imports always just work. Even 'Go to Definition' just assumes it should open the JS file.
I'd like there to be a jsconfig option to disable this behavior and require a file extension to be specified.
I'm asking because extensionless imports don't really work in the browser if you're not using a module bundler. It can only work if the HTTP server supports extensionless imports, which is a big ask.
The text was updated successfully, but these errors were encountered: