microsoft / microsoft/TypeScript

Configurable import suggestions to override global types

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

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

Domain: LS: Quick Fixes Needs Proposal Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Search Terms

Suggestion

In our code base we have a module export called Option which we use very often.

However, if we try to reference Option in a module where it's not currently imported, we will not get import suggestions/fixes for this.

This is because there is already a (different) global type of the same name, provided by the dom lib types.

I would like to be able to configure TypeScript and/or VS Code so that I do have import suggestions for Option.

Suggestion: any time a module references a global value, and the project has a module export of the same name, provide an import suggestion for that.

Potential caveat of this suggestion: what happens when you select "add all missing imports"? Ideally I would want it to import my Option, but what if I intentionally wanted to use the global version instead?

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

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

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

はじめの一歩

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

調査の方向性

まず、グローバルな DOM 型と同じ名前を持つモジュールエクスポートに対して要求されている TypeScript および/または VS Code のインポート候補の動作を確認します。明示的な候補と「不足しているすべてのインポートを追加」が、モジュールエクスポートとグローバル版のどちらを選択するかを定義します。動作を設定可能にし、意図的なグローバル使用のケースが引き続き明確であれば完了です。

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

評価

技術スタック
typescript
領域
developer-experience, tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

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

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