microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.99k stars 12.48k forks source link

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

Open ethanjdiamond opened 5 days ago

ethanjdiamond commented 5 days ago

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


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.

RyanCavanaugh commented 2 days ago

We need a repo we can clone here to try this out; there are multiple other variables in play that need to be checked first