TypeScript: Certain resolution-dependent enum emit isn't correctly flagged as an error under `isolatedModules`
π Search Terms
- isolatedModules
- enum
- cross module
- export
π Version & Regression Information
- This is a crash
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
Test on Playground with version 3.9.7 and version 5.2.2, got the same incorrect result.
β― Playground Link
π» Code
// @showEmit
// @isolatedModules: true
// @filename: foo.ts
export enum Foo {
A = 10
}
// @filename: index.ts
import { Foo } from "./foo";
export enum Bar {
B = Foo.A,
C
}
π Actual behavior
Please notice the value of Bar.C
import { Foo } from "./foo";
export var Bar;
(function (Bar) {
Bar[Bar["B"] = 10] = "B";
Bar[Bar["C"] = 11] = "C";
})(Bar || (Bar = {}));
π Expected behavior
Emit a warning or an error, and generate code that does not rely on other imports.
Example:
import { Foo } from "./foo";
export var Bar;
(function(Bar) {
Bar[Bar["B"] = Foo.A] = "B";
Bar[Bar["C"] = void 0] = "C";
})(Bar || (Bar = {}));
The Bar.C is void 0, since it cannot be refered.
Additional information about the issue
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 17 (11 by maintainers)
Thatβs a separate bug β TSC should probably disallow
"Infinity"and"NaN"as keys the same way as it disallows"3".