Skip to content

Add file extensions when auto-completing import paths #19019

Closed
@mjbvz

Description

@mjbvz

From @Rich-Harris on October 6, 2017 14:58

  • VSCode Version: Code 1.17.0 (be377c0faf7574a59f84940f593a6849f12e4de7, 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?

Copied from original issue: microsoft/vscode#35730

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Completion ListsThe issue relates to showing completion lists in an editorFixedA PR has been merged for this issueSuggestionAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions