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
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
### 🔎 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.
Beitragsleitfaden
Rechercherichtung
Kompiliere das bereitgestellte const-enum-Beispiel mit tsc im Watch-Modus erneut, wobei du zuerst isolatedModules und anschließend preserveConstEnums in tsconfig.json umschaltest. Vergleiche die erzeugte Ausgabe mit einer frischen Kompilierung und verfolge anschließend die Konfiguration des Watch-Modus sowie die Pfade zur Invalidierung der Ausgabe. Als abgeschlossen gilt die Aufgabe, wenn eine Änderung an isolatedModules dazu führt, dass const enums erneut ausgegeben werden, ohne einen vollständigen Neustart zu erfordern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- build-system, compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100