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
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 132
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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Reproduire l’exemple de const enum fourni avec tsc en mode watch, en basculant d’abord isolatedModules, puis preserveConstEnums dans tsconfig.json. Comparer la sortie émise avec une nouvelle compilation, puis suivre la configuration du mode watch et les chemins d’invalidation de l’émission. Le travail est terminé lorsque la modification de isolatedModules entraîne la réémission des const enums sans nécessiter un redémarrage complet.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- build-system, compilers
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100