microsoft / microsoft/TypeScript

VSCode auto-import ignores typescript.preferences.importModuleSpecifierEnding when using a path from the package.json imports

Open
#60,423 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs More Info
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.95.1
  • OS Version: MacOS 14.7

I have these settings in VSCode:

{
   "javascript.preferences.importModuleSpecifierEnding": "minimal",
   "typescript.preferences.importModuleSpecifierEnding": "minimal"
}

I have these setting in my package.json:

"imports": {
    "#src": ["./src/index.ts", "./src/index/tsx"],
    "#src/*": [
      "./src/*",
      "./src/*.ts",
      "./src/*.tsx",
      "./src/*/index.ts",
      "./src/*/index.tsx"
    ]
  },

I have these settings in my tsconfig.json

"target": "esnext",
"module": "esnext",
"moduleResolution": "bundler",

However, when I auto-import something that starts with #src/, it automatically appends a .js to the import (or a .ts if I have allowImportingTsExtensions on. This is ignoring my settings to use the minimum module specifier ending I set in VSCode.

It looks like the addition of the .ts functionality was added in this bugfix: https://github.com/microsoft/TypeScript/issues/52167. I'm not sure why it wasn't set to respect the vscode settings.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the auto-import behavior using the reported package.json imports, tsconfig.json settings, and VS Code preferences. Start by tracing TypeScript's auto-import module-specifier handling, then verify that imports using paths such as #src/ respect the configured minimal ending without regressing the existing .js or .ts behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.