Skip to content

Fix Issue #39155 (importModuleSpecifierEnding does not apply for module specifier completions) #42467

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

Merged
merged 4 commits into from
Mar 22, 2021

Conversation

Simar-B
Copy link
Contributor

@Simar-B Simar-B commented Jan 23, 2021

Fixes #39155

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jan 23, 2021
@ghost
Copy link

ghost commented Jan 23, 2021

CLA assistant check
All CLA requirements met.

@Simar-B Simar-B marked this pull request as ready for review January 30, 2021 06:48
Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@andrewbranch andrewbranch merged commit 4622718 into microsoft:master Mar 22, 2021
@Simar-B
Copy link
Contributor Author

Simar-B commented Mar 22, 2021

My pleasure!

@AlCalzone
Copy link
Contributor

AlCalzone commented Jun 19, 2021

@andrewbranch this does not seem to have any effect for me in TypeScript 4.3. With

	"javascript.preferences.importModuleSpecifierEnding": "js",
	"typescript.preferences.importModuleSpecifierEnding": "js",

TypeScript defaults to importing a .ts file and then complains that the import may not end in .ts:
grafik
grafik

@silkfire
Copy link

Why are you storing TypeScript code in .js files?

@AlCalzone
Copy link
Contributor

@silkfire
Copy link

These are two separate things. If you don't want the linter to complain you need to set that in the settings, so the TS Server knows what extensions you are expecting in your imports.

@AlCalzone
Copy link
Contributor

AlCalzone commented Jun 19, 2021

Did you even read my first comment? I've set the setting to use a js extension, but TypeScript adds a ts extension instead. It then complains about the ts extension and proposes a js extension, which is what I've wanted anyways.

Side note: It would be even better to not have to deal with this, but we'll have to wait for the TypeScript team to finalize the ESM support for that.

@silkfire
Copy link

silkfire commented Jun 19, 2021

I'm sorry, I didn't mean to misunderstand you. That must surely be a bug as specifying "js" should not result in a spurious .ts extension being suggested by TS for files that aren't even TypeScript files.

I see, what would the upshot of that be?

@AlCalzone
Copy link
Contributor

in a spurious .ts extension being suggested by TS for files that aren't even TypeScript files.

They are TypeScript files. But importing them with a .js extension is currently the recommended way to do ESModules, because TypeScript does not yet change the extension during compilation. So we need to specify the filename the file is going to have at runtime, which is also why TS suggests using a .js extension.

@andrewbranch
Copy link
Member

@AlCalzone I believe you’re describing #44374, fixed by #44602.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

importModuleSpecifierEnding does not apply for module specifier completions (manual imports)
5 participants