microsoft / microsoft/TypeScript
Allow importModuleSpecifier: "relative" to be overridden for explicitly configured "paths" in a jsconfig/tsconfig
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
This is a follow-up issue of https://github.com/microsoft/TypeScript/issues/40139
As per the docs, once you've imported a variable somewhere, vscode knows where to find it (bypassing the issue above).
I want all my code to be imported with relative imports everywhere for consistency. so I set "javascript.preferences.importModuleSpecifier": "relative". However, I don't want relative paths to be used when importing from a module declared in tsconfig's paths, as I specifically put it there so it can be resolved as an absolute import for convenience.
Clearly these 2 settings are conflicting, but I wonder if the current compromise is the best one (i.e. settings.json wins over tsconfig)?
I would expect to be able to auto-import variables from my paths module absolutely, even though I want everything else to import relatively.
- VSCode Version: Insiders
- OS Version: macOS 10.15.6
Steps to Reproduce:
- Clone this repo:
https://github.com/Floriferous/paths-resolution - Go to branch
absolute-import-paths - Notice
test2.jsimportssomeVarproperly - Open
test.js, try to auto-importsomeVar, notice intellisense only suggests a relative import
Does this issue occur when all extensions are disabled?: Yes
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まずパス解決の再現から始めます。特に test.js、test2.js、および参照されている jsconfig/tsconfig の paths 設定を確認し、相対パス優先を有効にした状態で auto-import の候補を再現してください。明示的に設定されたパスに対する auto-import の処理を追跡してください。paths ベースの import が絶対パスとして提案され、それ以外の import は相対パスのままになれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript, vscode
- 領域
- developer-experience, tooling
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100