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

未关闭
#63,223 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Bug Domain: flag: isolatedDeclarations
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

### 🔎 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.

贡献指南

打开贡献指南

调研方向

使用 tsc 在 watch 模式下重现提供的 const enum 示例,先在 tsconfig.json 中切换 isolatedModules,然后切换 preserveConstEnums。将 emit 的输出与全新编译的结果进行比较,然后跟踪 watch 模式的配置和 emit invalidation 路径。当更改 isolatedModules 会使 const enums 重新 emit,而无需完全重启时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
build-system, compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。