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.
Aperta
Nessuno ha ancora preso questa issue.
Awaiting More Feedback
Suggestion
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔍 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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con l’esempio minimo di tipo tupla nell’issue e segui come il type checker di TypeScript risolve l’accesso indicizzato T1[0] quando la tupla inizia con un elemento rest. Il lavoro è completo quando il tipo inferito è string | number invece di string | number | boolean e i test esistenti del type checker sono stati estesi per coprire questo caso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100