microsoft / microsoft/TypeScript
Allow mapped tuples to have behaviour based on index
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
Search Terms
mapped tuples index
Suggestion
I want to be able to create a tuple from function parameters and have all elements in the tuple optional other than the firstK
Use Cases
I am trying to create a curry implementation that allows you to curry any number of parameters. The first parameter must be specified but all other params are optional.
Would be good to be able to remove the last param as well.
Examples
something along the lines of
type OptionalExceptFirst<T> = {
[K in keyof T]:isFirst ? ? T[K] : T[K];
};
type AllExceptLast<T> = {
[K in keyof T]:isLast ? never : T[K];
};
The syntax will need some work hopefully the intended functionality is clear.
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.
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. Prüfe daher zunächst, wie sich gemappte Tupel derzeit verhalten und wie TypeScript Tupelpositionen darstellt. Kläre die beabsichtigten Regeln für die Optionalität anhand des ersten und letzten Index, bevor du eine Implementierung und Tests vorschlägst; als erledigt würde die Aufgabe ein abgestimmtes Design sowie validiertes Compilerverhalten erfordern.
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
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100