Skip to content

VS Community and TS: auto-import adds '.js' extension to the module name, while auto completion not #35926

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

Closed
AbuDawood opened this issue Dec 30, 2019 · 4 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@AbuDawood
Copy link

visual studio 2019 community,
for the autocomplete during import the suggested modules are as expected (module name without extension), However, when typing ex. a class name and want to auto-import the incloser module it gets added with .js extension !! what's wrong

  • screenshot for autocomplete the import syntax
    image

  • screenshot for auto import suggestions
    image

@AbuDawood AbuDawood changed the title auto-import adds '.js' extension to the module name, while auto completion not VS Community and TS: auto-import adds '.js' extension to the module name, while auto completion not Dec 30, 2019
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 31, 2019

So some context: for path completions, we currently we find the first existing import that's relative, and then figure out if it uses an extension. If so, we provide paths with .js files: #20624

However, there was talk of following up and making extensions for import paths configurable: #19019 (comment)

@AbuDawood
Copy link
Author

AbuDawood commented Dec 31, 2019

Thank you @DanielRosenwasser for your reply.
The issue is that I am working on a project that uses Webpack i.e. supports the import of modules with extensionless syntax.
According to the mentioned situation, the provided option is not helpful.

@daramasala
Copy link

So some context: for path completions, we currently we find the first existing import that's relative, and then figure out if it uses an extension. If so, we provide paths with .js files: #20624

However, there was talk of following up and making extensions for import paths configurable: #19019 (comment)

Mine is a typescript project. None of my imports use '.js' (they are all without any extension) yet new auto imports are created with '.js'.
I have another project with exactly the same tsconfig.json file and there, imports are created without an extension.
I would be happy for some guidance on which files/configurations would help troubleshoot the issue (as I said, I don't think it's the tsconfig file since the same file in a different project yields extensionless imports).

@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Jan 31, 2020
@andrewbranch
Copy link
Member

Lots of things around this have changed since this issue was opened. Certain compiler options indicate that extensions are required by the module system where the code is intended to run. Beyond that, there are editor preferences, and when not set and the compiler options allow multiple options, an attempt to match the style of the existing file is made. Given how many features have been added (and bugs fixed), I’m going to close this. Feel free to open a new one with complete repro steps if you’re still experiencing buggy or confusing behavior.

@andrewbranch andrewbranch closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants