microsoft / microsoft/TypeScript
mapped type with remapped keys unexpectedly widens type
Aperta
@weswigham ci sta già lavorando.
Dal 2/2/2024.
Has Repro
Needs Investigation
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 Search Terms
keyof, string, record
🕗 Version & Regression Information
- This changed between versions 4.4.4 and 4.5.5
⏯ Playground Link
No response
💻 Code
type R = { [K in keyof Record<string,unknown> as K]: unknown; };
// ^?
type K = keyof R;
// ^?
let s:string = "a" as K
🙁 Actual behavior
keyof R is string | number.
🙂 Expected behavior
keyof R is string.
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.