You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constenumBebra{}// All of these compile and break runtimeconsole.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.testBebra['test']constc1=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
The text was updated successfully, but these errors were encountered:
Not a duplicate, but tangentially related to #40740. In both cases there's an inherent design limitation in that TS isn't able to represent (in the type system) an object that doesn't inherit from Object.prototype.
🔎 Search Terms
const enum Object properties constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.1.6#code/MYewdgzgLgBApmArgWxgITgIwE4EMYDeAvgLABQ5A9JTAIIA29MIAZjFABZwRwyjIAHAJb1euMABMYOOLgDWMbIjBQhyOOVCQQogHT0QAcwAUGHLl1boS4FBDYAlJvAQdcfUdNY8ujrggA8gDuYAAK2CACcNhQAJ5OZFZuHiZmPkIQ4SB2cVEBLAlJegap3hYCEVExsQCSEACiSOp4mKKFLsklXua6dgAyIMC4ogDKUNhCYIbt2sWeaRZ2YxNTM65zpT0AbsOIcPkJVDQAKlw8MBIgMGDZfCCCIrzG-vAAHlG2cBIJ1OhlvdwoEc-uYANoAciggPBAF1gVZYMAAIwwAC8ILw5CAA
💻 Code
🙁 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
The text was updated successfully, but these errors were encountered: