No extensions in import paths in .d.ts files in NPM packages

Hello!

For example for the core package @babylonjs/core - npm .d.ts files contain import paths without extensions.

But there is "type": "module", in the package.json file, so i believe extensions are necessary, even for declaration files (because of this? Modules: ECMAScript modules | Node.js v23.9.0 Documentation). As otherwise these are not considered valid ESM imports and get ignored.

There already are .js extensions in .js files imports, so those are just fine.

If my point above is valid, would it be possible to add .ts extensions to import paths in .d.ts files then?

Thanks!

P.S. I understand that it would probably mean adding extensions to all imports in the source files, but a) maybe i’m wrong and there’s some magic build parameter that will do that, or b) maybe something like that has already been planned?..

Here is an open issue especially for you :slight_smile:

Was researched, and there is a plan forward.

3 Likes

oh! sorry, haven’t seen that one, guess i used the wrong search phrases… thanks a lot!

2 Likes