microsoft / microsoft/TypeScript

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

オープン
#60,423 コメント 3 件 リアクション 6 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Needs More Info
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

報告されている package.json の imports、tsconfig.json の設定、VS Code の環境設定を使って、auto-import の動作を再現します。まず TypeScript のモジュール指定子の処理を追跡し、次に #src/ のようなパスを使用する imports が、既存の .js または .ts の動作を後退させることなく、設定された最小の末尾を尊重することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript, vscode
領域
developer-experience, tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。