Skip to content

Add file extensions when auto-completing import paths #35730

@Rich-Harris

Description

@Rich-Harris
  • VSCode Version: Code 1.17.0 (be377c0, 2017-10-05T06:07:51.906Z)
  • OS Version: Darwin x64 16.7.0
  • Extensions:
Extension Author (truncated) Version
Handlebars and 0.2.0
vscode-eslint dba 1.3.2
prettier-vscode esb 0.24.0
vscode-import-cost wix 2.5.0

Steps to Reproduce:

  1. Open or create a JavaScript file
  2. Start typing import x from './ followed by the name of a sibling file

Reproduces without extensions: Yes


When you start writing a local import statement, the intellisense helper will offer up foo and bar rather than foo.js and bar.js. Extensionless imports is a Node idiom that is incompatible with browser module loaders — adding the file extension would increase browser compatibility with no ill-effect on Node apps (to the contrary, it speeds up module resolution, and I'd argue it makes code more explicit and readable).

I wonder if you would consider changing the behaviour to add file extensions by default?

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalityjavascriptJavaScript support issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions