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

Typescript NodeNext path alias with extension #191

Open
WoodyWoodsta opened this issue Oct 10, 2022 · 7 comments
Open

Typescript NodeNext path alias with extension #191

WoodyWoodsta opened this issue Oct 10, 2022 · 7 comments

Comments

@WoodyWoodsta
Copy link

I have a typescript project with moduleResolution: 'NodeNext'. In my tsconfig.json, I have set up an alias which points directly to a file. In the ES spec, this would be with the file extension, and thus should be in the alias target:

tsconfig.json

{
	"paths": {
		"alias": ["path/to/specific/file.mjs"]
	}
}

Eslint complains, if I try:

import something from 'alias';

with "Unable to resolve path to module 'alias'".

Am I configuring this incorrectly, or is this not yet supported?

@WoodyWoodsta
Copy link
Author

I forgot to add that Typescript correctly resolves to the file, so this isn't an issue with the alias specification.

@JounQin
Copy link
Collaborator

JounQin commented Oct 11, 2022

If you still have any issue, please provide a runnable reproduction.

@WoodyWoodsta
Copy link
Author

@mackermans
Copy link

@JounQin Did you manage to have a look at the reproduction above?

I'm experiencing the same issue on v3.6.1. It also seems related to #234.

@JounQin
Copy link
Collaborator

JounQin commented Jan 12, 2024

Sorry, I've totally forgotten about this issue, I'll take a look when I'm free at this weekend, or you can help to debug first.

@EdisonSu768
Copy link

EdisonSu768 commented Jan 16, 2024

The fix is easy:

{
	"paths": {
		"alias": ["path/to/specific/file.mts"]
	}
}

@JounQin
Copy link
Collaborator

JounQin commented Jan 16, 2024

@EdisonSu768 Maybe we can support auto mapping which is the behavior of TypeScript itself.

See

'.mjs': ['.mts', '.d.mts', '.mjs'],

Use options.extensionAlias for this purpose.

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

No branches or pull requests

4 participants