microsoft / microsoft/TypeScript
Enum declarations should consistently disallow computed keys
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Bug Report
🔎 Search Terms
Computed property names are not allowed in enumsenum declaration computed
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about enums
⏯ Playground Link
Playground link with relevant code
💻 Code
let y = "y";
type z = "z";
enum Foo {
['x'],
[{}],
[y],
[z]
}
🙁 Actual behavior
TS reports Computed property names are not allowed in enums. for [{}], [y] and [z], while it allows ['x'] (in contraddiction with the error message).
🙂 Expected behavior
All of them should be an error, for the reason reported by the error.
📚 Context
This came up at https://github.com/babel/babel/issues/12683: we can implement the current TS behavior in Babel, but I'd first like to check if TS is expected to report an error for ['x'].
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
Riprodurre il comportamento dal TypeScript Playground collegato usando l’esempio di enum con ['x'], [{}], [y] e [z]. Tracciare la diagnostica della proprietà calcolata dell’enum da quell’esempio; è completato quando tutte e quattro le dichiarazioni producono coerentemente l’errore segnalato, con copertura per i casi dimostrati.
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
- Specificata chiaramente
- Idoneità per principianti
- 35/100