microsoft / microsoft/TypeScript
`never` as keyof tuples/arrays behaves the same as `number`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 Search Terms
tuple keyof never, tuple[never], array keyof never
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about this issue
Versions I tried:
- 5.2.2
- nightly (playground)
⏯ Playground Link
💻 Code
type A = {}[never] // ✅ never
type B = { a: string }[never] // ✅ never
type C = [][never] // ✅ never
type D = [string][never] // ❌ string
type E = string[][never] // ❌ string
type F = (string | number)[][never] // ❌ string | number
🙁 Actual behavior
After using a never key on tuples/arrays you get back the entirety of the tuple/array elements type.
🙂 Expected behavior
After using a never key on tuples/arrays you get back never, as when dealing with objects.
Additional information about the issue
Not sure if this has historical reasons to behave like it does, but couldn't find any specific info about it.
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 riproducendo il comportamento nel TypeScript Playground collegato, confrontando gli esempi di oggetto, tupla e array che usano never. Traccia la gestione degli accessi indicizzati da parte del compilatore per le chiavi di tuple e array; il lavoro è completato quando questi esempi vengono valutati come never in modo coerente con l'indicizzazione degli oggetti, con un'adeguata copertura di regressione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100