microsoft / microsoft/TypeScript

Have QuickInfo use import types to display type aliases that are not in scope

オープン
#23,642 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る

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

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

説明

Search Terms:
type alias, import, display, quickinfo, intellisense

Code

// @Filename: file1.ts
export type ComplicatedType<T, U> = { [K in Exclude<keyof T, U>]: T[K] } // could be anything here
export declare function getComplicatedType<T, U extends keyof T>(arg: T, exclude: U): ComplicatedType<T, U>

// @Filename: file2.ts
import { getComplicatedType } from "./file1"
interface SomeInterface {
    a: string
    b<T>(arg: T): T,
    c: { c2: string } | { c3: number },
    d?: boolean
}
declare const test: SomeInterface
const result = getComplicatedType(test, "a") // quickinfo on result currently displays something like:
/* const result: {
    b: <T>(arg: T) => T;
    c: {
        c2: string;
    } | {
        c3: number;
    };
    d: boolean | undefined;
} */

Current behavior:
The quick info type shown for result is a fully expanded anonymous type because ComplicatedType is not in scope in file2. Importing ComplicatedType in file2 makes quick info display const result: ComplicatedType<SomeInterface, "a">, but I don't think it's common to import a type alias purely for the quick info benefit if it isn't actually used anywhere in the file.

While the example above isn't that bad, in some cases (#18754, #23458) the fully expanded types can be so large that they actually cause a performance issue for the language service.

Suggested behavior:
Use import types from #22592 to display an accurate qualified reference to ComplicatedType. So in the example above quick info for result could instead display something like:

const result: import("./file1").ComplicatedType<SomeInterface, "a">

Which, although a little verbose, would be much more readable than many fully expanded types.

Related Issues:
#22592 added import types.

#18754, #23458, #6070, #13095 - Various issues related to the display of types.

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

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

はじめの一歩

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

調査の方向性

file1.ts/file2.ts の再現と、issue で説明されている QuickInfo の動作から始めます。issue #22592 の import types と、関連する type-display issues を確認します。QuickInfo がエイリアスを展開する代わりに、import("./file1").ComplicatedType<SomeInterface, "a"> のような修飾された import-type 参照を表示できれば完了です。

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

評価

技術スタック
typescript
領域
tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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