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

Preference for including file extension on auto imports #24779

Closed
mjbvz opened this issue Jun 7, 2018 · 5 comments · Fixed by #36725 or microsoft/vscode#90405
Closed

Preference for including file extension on auto imports #24779

mjbvz opened this issue Jun 7, 2018 · 5 comments · Fixed by #36725 or microsoft/vscode#90405
Assignees
Labels
Committed The team has roadmapped this issue Fix Available A PR has been opened for this issue Suggestion An idea for TypeScript VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jun 7, 2018

Search Terms

  • Auto imports
  • Preferences
  • File extensions

Suggestion

From microsoft/vscode#51259

Add a preference to include file extensions on auto import paths.

Use Cases

File extensions are required when working with browsers.

Examples

a.js:

export const abc = 123;

b.js

abc|

Trigger auto import on abc in b.js to get:

import { abc } from './a.js'

abc
@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Jun 7, 2018
@mhegazy mhegazy added the Suggestion An idea for TypeScript label Jun 8, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jun 8, 2018

PRs welcomed for adding support of file extension preference

@andrewbranch
Copy link
Member

andrewbranch commented Feb 10, 2020

This has actually existed in TS since #26177, but was never added to typescript-language-features. I just tried it and confirmed it works. From conversation in #28288, though, it sounds like we should maybe consider setting .js endings as the default for JS projects? @mjbvz @DanielRosenwasser thoughts? (Edit: Actually, I think this would still be a surprising default for most JS users—I don’t think it’s common in Node, and most frontend users still use a bundler.)

@wsmd
Copy link

wsmd commented May 6, 2020

Question related to microsoft/vscode#90405 - Is there an existing configuration that can achieve the same behavior for autosuggest when typing the import statement manually?

For example:

{
  "javascript.preferences.importModuleSpecifierEnding": "js",
}
import { someFunction } from './|';
                                ^ when picking a file from suggestions here,
                                  the file extension seems to always be omitted

@andrewbranch
Copy link
Member

I can’t immediately think of a reason why we shouldn’t respect that same setting for module specifier completions. @wsmd would you mind opening a new bug for this?

@wsmd
Copy link

wsmd commented May 6, 2020

Thanks @andrewbranch! Will do! I think it would be nice to have importModuleSpecifierEnding applies for both auto-imports and manual import suggestions 👍

Reported here https://github.com/microsoft/vscode/issues/97106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Fix Available A PR has been opened for this issue Suggestion An idea for TypeScript VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
5 participants