microsoft / microsoft/TypeScript
Default type parameter values always shown on hover
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 Search Terms
default parameters hover
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Es wird keine Quelldatei oder kein Test genannt. Beginne mit dem verlinkten TypeScript Playground und überprüfe den Hover für SomeHkt. Verfolge anschließend den Compilerpfad, der generische Typparameter formatiert. Erledigt ist es, wenn voreingestellte Parameter weggelassen werden, sobald sie nicht gesetzt oder explizit gleich ihren Standardwerten sind, einschließlich der genannten .d.ts- und isolatedDeclarations-Fälle.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers, developer-experience
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100