microsoft / microsoft/TypeScript

`keyof Readonly<string[]>` different from `keyof Readonly<T>` where T is string[]

Aperta
#60,231 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@ahejlsberg ci sta già lavorando.

Dal 16/10/2024.

Needs Investigation
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms

keyof Readonly array

🕗 Version & Regression Information

Latest to date

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/C4TwDgpgBAKgjFAvFAShAhgEwPYDsA2IAPAM7ABOAlrgOYDaAugHwDcUA9O1ORjgSFDJVajALAAoUJFQJkAawghsAM1hw2nKAqWqeWPIUEVq9BhIlToAaUUB5ZWn38iMJki2KVqXgeKuWFuDQKABM7jYg9o58hKTGIswaXIAy5B46RsKmEkA

💻 Code
type T1 = Readonly<string[]>; // readonly string[]
type R1 = keyof T1; // keyof readonly string[]

type KeyOfReadonly<T> = keyof Readonly<T>;
type R2 = KeyOfReadonly<string[]>; // ❌ keyof string[]
🙁 Actual behavior

doesn't work

🙂 Expected behavior

works

Additional information about the issue

What can I say, I really hope this is not the intended behavior.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.