microsoft / microsoft/TypeScript

Default type parameter values always shown on hover

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

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

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

説明

🔎 Search Terms

default parameters hover

🕗 Version & Regression Information
  • This is the behavior in every version I tried
⏯ Playground Link

https://tsplay.dev/mpkKgN

💻 Code
export abstract class Kind<
    hkt extends (...args: any[]) => unknown = (...args: any[]) => unknown
> {
    declare readonly args: unknown
    abstract readonly hkt: hkt
}

// Hover: Kind<(...args: any[]) => unknown>
type SomeHkt = Kind
🙁 Actual behavior

Kind's defaulted parameter is displayed on hover.

🙂 Expected behavior

Defaultable generic parameters should not be printed if they are unset in the instantiation and/or explicitly set to their default value.

This could also apply to .d.ts, although that's viewed less often.

Additional information about the issue

This is obviously not a bug but a request that would help reduce visual clutter for many types. Types with several parameters with non trivial default values are relatively common, especially when those defaults are expanded recursively.

It also occurred to me that when combined with autofixes, this could also make types written to a user file much more usable. When using --isolatedDeclarations, one of the biggest problems with the autofixes is that they'd often pull in types with several generic parameters with long defaults, and end up writing some massive type instead of just a single identifier.

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

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

はじめの一歩

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

調査の方向性

ソースファイルもテストも指定されていません。リンクされた TypeScript Playground から始めて SomeHkt のホバーを確認し、その後、ジェネリック型パラメーターをフォーマットするコンパイラーパスを追跡してください。未設定の場合、または明示的にデフォルト値と等しい場合にデフォルト値付きパラメーターが省略され、記載された .d.ts および isolatedDeclarations のケースも含まれることが完了の条件です。

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

評価

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

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

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