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

Created on 31 Dec 2019  路  3Comments  路  Source: microsoft/TypeScript

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

Awaiting More Feedback Suggestion

Most helpful comment

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).

All 3 comments

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: https://github.com/microsoft/TypeScript/pull/20624/

However, there was talk of following up and making extensions for import paths configurable: https://github.com/microsoft/TypeScript/issues/19019#issuecomment-378373530

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.

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).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quantuminformation picture quantuminformation  路  273Comments

Gaelan picture Gaelan  路  231Comments

born2net picture born2net  路  150Comments

disshishkov picture disshishkov  路  224Comments

rwyborn picture rwyborn  路  210Comments