Skip to content

File extensions in import autocomplete suggestions #42157

Closed

Description

@a-ejs

vscode 1.52.1

With javascript.preferences.importModuleSpecifierEnding set to "js":

Given a file ./foo.js that exports foo, typing

import foo from "./

brings up a suggestion for ./foo, without the extension.

In contrast, simply typing foo and letting auto import do the work correctly adds

import foo from "./foo.js";

at the top of the file, respecting the setting value.

This seems odd, especially considering that in most cases with ES modules specifying the extension isn't optional.


Also: if foo has mjs extension, it's not suggested at all (#27957). However its exports still appear as auto import suggestions, and selecting them does nothing (besides producing an 'unknown extension' error).

Activity

  1. andrewbranch commented on Dec 30, 2020

    @andrewbranch
    Member

    This seems reasonable to me, looks like we’d want to pass the preferences in stringCompletions.ts all the way down into getCompletionEntriesForRelativeModules and use that preference in the getExtensionOptions() call.

  2. andrewbranch commented on Jan 4, 2021

    @andrewbranch
    Member

    Duplicate of #39155

  3. typescript-bot commented on Jan 7, 2021

    @typescript-bot
    Contributor

    This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions