-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Milestone
Description
🔎 Search Terms
const enum Object properties constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf
🕗 Version & Regression Information
- This seems like a bug
- This is the behavior in every version I tried (3.3-5.3 nightly)
⏯ Playground Link
💻 Code
const enum Bebra {}
// All of these compile and break runtime
console.log(Bebra.constructor)
console.log(Bebra.hasOwnProperty)
console.log(Bebra.isPrototypeOf)
console.log(Bebra.propertyIsEnumerable)
console.log(Bebra.toLocaleString)
console.log(Bebra.toString)
console.log(Bebra.valueOf)
// These do not compile (as expected)
Bebra.test
Bebra['test']
const c1 = Bebra
🙁 Actual behavior
TS Allows usage of Object
methods on a const enum, which breaks runtime because const enums are ment to be fully erased.
🙂 Expected behavior
TS should disallow such things as it does with other properties.
Additional information about the issue
No response