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
// @experimentalDecorators: truefunctionmethodDecorator(value: string): any{return()=>{};}//@methodDecorator(MyEnum.value1) // Correctly reports Enum 'MyEnum' used before its declaration (TS2450)exportclassMyClass{
@methodDecorator(MyEnum.value1)// No error reportedpublicfoo(): void{}}enumMyEnum{value1="value1",}
🙁 Actual behavior
No TS2450 "Enum 'MyEnum' used before its declaration" is reported.
At runtime, this code crashes during the initial script execution:
C:\repos\TS2450_decorator_repro\program.js:19
methodDecorator(MyEnum.value1) // No error reported
^
TypeError: Cannot read properties of undefined (reading 'value1')
at C:\repos\TS2450_decorator_repro\program.js:19:32
at Object.<anonymous> (C:\repos\TS2450_decorator_repro\program.js:22:2)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
🙂 Expected behavior
TS2450 (and other similar errors like 2448 for Block-scoped variables or 2449 for classes) should be correctly reported.
The text was updated successfully, but these errors were encountered:
This issue caught us off guard when we switched to using isolatedModules. This causes const enums to be preserved as if preserveConstEnums was set, which meant that a value that used to compile in stopped doing so, and no error was raised during build due to this issue.
In the code example given in the issue above, using 4.7:
Bug Report
🔎 Search Terms
decorator
enum
used before its declaration
TS2448, TS2449, TS2450
isolatedModules
preserveConstEnums
🕗 Version & Regression Information
⏯ Playground Link
Workbench Repro
💻 Code
🙁 Actual behavior
🙂 Expected behavior
TS2450 (and other similar errors like 2448 for Block-scoped variables or 2449 for classes) should be correctly reported.
The text was updated successfully, but these errors were encountered: