Feature: disable extensionless imports · Issue #28288 · microsoft/TypeScript (original) (raw)
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.
// index.js import { Foo } from './foo'; // extensionless
I'd like there to be a jsconfig option to disable this behavior and require a file extension to be specified.
import { Foo } from './foo';
^^^^^^^ No definition found for 'foo'
// fix
- import { Foo } from './foo';
- import { Foo } from './foo.js';
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.