microsoft / microsoft/TypeScript

Allow importModuleSpecifier: "relative" to be overridden for explicitly configured "paths" in a jsconfig/tsconfig

オープン
#40,337 コメント 1 件 リアクション 4 件 担当者 0 名 GitHub で見る

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

Awaiting More Feedback Suggestion
主要言語
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:

  1. Clone this repo: https://github.com/Floriferous/paths-resolution
  2. Go to branch absolute-import-paths
  3. Notice test2.js imports someVar properly
  4. Open test.js, try to auto-import someVar, notice intellisense only suggests a relative import

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

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

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

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