microsoft / microsoft/TypeScript
`instantiateMappedTupleType` should not use array index as mapping key, at least it's not in an appropriate way
Aperta
@ahejlsberg ci sta già lavorando.
Dal 26/8/2024.
Needs Investigation
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 Search Terms
instantiateMappedTupleType
🕗 Version & Regression Information
- This is the behavior in every version I tried.
⏯ Playground Link
💻 Code
type Keys<T> = { [K in keyof T]: K };
type Foo<T extends any[]> = Keys<[string, string, ...T, string]>; // ["0", "1", ...Keys<T>, number]
type A = Foo<[string]>; // ["0", "1", "0", number]
type B = Keys<[string, string, ...[string], string]>; // ["0", "1", "2", "3"]
🙁 Actual behavior
After instantiating the Keys<[string, string, ...T, string]> to ["0", "1", ...Keys<T>, number] in advance, the position of T is lost, resulting in incorrect indexes.
🙂 Expected behavior
Option 1: look up real indexes during instantiating.
type Foo<T extends any[]> = Keys<[string, string, ...T, string]>; // ["0", "1", ...Keys<T>, ...Keys<[string]>]
type A = Foo<[string]>; // ["0", "1", "2", "3"]
Option 2: don't use indexes
type Foo<T extends any[]> = Keys<[string, string, ...T, string]>; // [number, number, ...Keys<T>, number]
type A = Foo<[string]>; // [number, number, number, number]
Additional information about the issue
No response
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.
Valutazione
Questa issue non è ancora stata valutata.