microsoft / microsoft/TypeScript
When the initial element of the tuple is a rest element, it is not possible to correctly infer the type of the initial element.
Offen
Dieses Issue hat noch niemand übernommen.
Awaiting More Feedback
Suggestion
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔍 Search Terms
initial element of the tuple is a rest element
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
type T1 = [...string[], number, boolean]
declare const head: T1[0]
// Actual: string | number | boolean
// Expected: string | number
📃 Motivating Example
💻 Use Cases
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
Beginne mit dem minimalen Beispiel für einen Tupeltyp im Issue und verfolge, wie der TypeScript-Checker den indizierten Zugriff T1[0] auflöst, wenn das Tupel mit einem Rest-Element beginnt. Als abgeschlossen gilt die Änderung, wenn der inferierte Typ string | number statt string | number | boolean ist und die bestehenden Tests des TypeScript-Checkers um diesen Fall erweitert wurden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100