microsoft / microsoft/TypeScript
support match for type infer
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Search Terms
Suggestion
As a suggestion, there is any plans to support match keyword in type inference to simplify the type destruction and T extends P test and make code more expressive.
Support match in type inference.
Use Cases
type Infer<T> = match T {
{ prop: infer P } => P
[infer P] => P
_ => never // default
}
The above is equal to:
type Infer<T> = T extends { prop: infer P }
? P
: T extends [infer P]
? P
: never
## Checklist
My suggestion meets these guidelines:
* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
* [x] This wouldn't change the runtime behavior of existing JavaScript code
* [x] This could be implemented without emitting different JS based on the types of the expressions
* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).
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
Das Issue nennt keine Dateien, Tests oder Einstiegspunkte. Beginne damit, die vorgeschlagene match-basierte Typinferenz mit den Conditional-Type-Beispielen in der Beschreibung zu vergleichen; abgeschlossen ist die Aufgabe, wenn Syntax, Inferenzverhalten und Standardfall einvernehmlich festgelegt sind und ein entsprechender Implementierungsplan vorliegt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100