Closed as not planned
Description
π Search Terms
"enum"
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about Enums
β― Playground Link
π» Code
enum Messages {
HELLO = "bye"
}
enum Messages {
BYE = "bye"
}
const c = Messages.BYE;
π Actual behavior
declarations
declare enum Messages {
HELLO = "bye"
}
declare enum Messages {
BYE = "bye"
}
declare const c = Messages.HELLO;
π Expected behavior
declarations
declare enum Messages {
HELLO = "bye"
}
declare enum Messages {
BYE = "bye"
}
declare const c = Messages.BYE;
Additional information about the issue
I was experimenting with using a global enum to differentiate messages from a message broker like the BroadcastChannel browser API. I was hoping to get compile-errors when a string enum gets expanded by a key with an already present value. It makes sense, that there is no error at compile-time, but the result should at least be consistent between the JavaScript and .d.ts results.
The idea relates to #53013