microsoft / microsoft/TypeScript

Explicit variance annotations for built-in .d.ts files

Offen
#62,954 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Experimentation Needed In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

While profiling some projects using typeslayer, I've noticed that according to the type checking traces some time is spent calculating the type variance of common types like Promise<T> and others.

I've explicitly annotated some of these generic types, and I've verified that it that sped up typechecking for some of my complex use-cases.
I've verified that these speed-ups also translate to tsgo by checking with hyperfine.

I'd like to ask if a PR to add explicit type variance to some of the most commonly used library types could be a valuable addition? I could set up a PR so some performance tests could be run to see if it works in aggregate, I just wanted to ask if it's something that aligns with the projects' goals and to maybe understand if this was tried already

Based on my limited understanding the pros would be:

  • More people learning about variance and explicit variance annotations
  • Slightly increased performance in some complex scenarios

The cons would be:

  • Different error messages as now we'd see super and sub prefixes that might confuse users
  • larger size on the wire/disk
  • higher overhead to parse

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Es werden keine Quelldateien oder Tests genannt. Beginne damit, die integrierten .d.ts-Bibliothekstypen und die im Issue beschriebenen Typprüfungs-Traces zu überprüfen, und vergleiche anschließend die Messungen von tsgo mit hyperfine. Als abgeschlossen gilt die Einigung auf die häufig verwendeten Zieltypen sowie der Nachweis der aggregierten Performance- und Diagnoseauswirkungen durch Performance-Tests.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers, performance
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.