Skip to content
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

Consider allowImportingTsExtensions #31

Open
fregante opened this issue Aug 21, 2024 · 2 comments
Open

Consider allowImportingTsExtensions #31

fregante opened this issue Aug 21, 2024 · 2 comments

Comments

@fregante
Copy link
Contributor

https://www.typescriptlang.org/tsconfig/#allowImportingTsExtensions

Required for:

import {addTests} from './collector.ts';

Which is required by node --experimental-strip-types

This is unrelated/unaffected by #29

I don't know what are the consequences of allowing .ts imports though. Also XO currently enforces .js extensions:

require file extension '.js'. (n/file-extension-in-import) XO
@sindresorhus
Copy link
Owner

sindresorhus commented Aug 21, 2024

Enabling allowImportingTsExtensions means that it's easy for users to make the mistake of using .ts instead of .js. I think this will cause a lot of problems. I'm not sure it makes sense to introduce this pitfall just to enable the user of a highly experimental Node.js feature. It seems like for now, you should just manually enable that in the projects tsconfig. In addition, it's also unclear whether it has any other hidden gotchas.

@fregante
Copy link
Contributor Author

experimental Node.js feature

Yeah we'll definitely have to wait and see if it's worth it.

whether it has any other hidden gotchas

It is a tricky situation.

  • Node has to look for the .ts file because it's reading a .ts file source;
  • packages have to look for a .js file because they have .js entry points.

My guess is that allowImportingTsExtensions exclusively makes sense for projects/applications, and not for modules that are meant to be distributed.

I think Node is the only tool that requires this, and it's experimental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants