microsoft / microsoft/TypeScript
Toggling `isolatedModules` in `tsconfig.json` while running the compiler in `watch` mode, doesn't re-emit `const enums`, unlike toggling `preserveConstEnums`, which does
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- PR merge metrics
- PR metrics pending
Description
### 🔎 Search Terms
isolatedModules enums not re-emitted on watch mode
### 🕗 Version & Regression Information
Tested on `6.0.1-rc` and `6.0.0-dev.20260309`
I didn't research if this is a regression or not. It may have always been like this but never reported.
### ⏯ Playground Link
_No response_
### 💻 Code
```ts
const enum TestEnum {
a = 1,
b = 3,
c = 5,
}
const x = TestEnum.b
```
### 🙁 Actual behavior
Toggling `isolatedModules` doesn't change the emitted code when running `tsc` in `watch` mode. However, if the compilation is redone, it does re-emit correctly.
### 🙂 Expected behavior
Should modify the emitted code for `const enums` when the option is changed on `watch` mode, since it does change when re-compiling from scratch.
### Additional information about the issue
For comparison, toggling `preserveConstEnums` in `tsconfig.json` does correctly modify the emitted code in `watch` mode.
Clarification: the issue occurs when `preserveConstEnums` is not defined at all in `tsconfig.json`, so the emit behavior for `const enum`s is implicit from it.
Contributor guide
Research direction
Reproduce the provided const enum example with tsc in watch mode, first toggling isolatedModules and then preserveConstEnums in tsconfig.json. Compare the emitted output with a fresh compilation, then trace the watch-mode configuration and emit invalidation paths. Done means changing isolatedModules causes const enums to be re-emitted without requiring a full restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100