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 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Domain: flag: isolatedDeclarations
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された const enum の例を tsc の watch モードで再現し、まず tsconfig.json の isolatedModules を切り替え、次に preserveConstEnums を切り替えます。出力された結果を新規コンパイルの結果と比較し、その後、watch モードの構成と emit の無効化パスを追跡します。isolatedModules の変更によって、完全な再起動を必要とせずに const enums が再度 emit されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
build-system, compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。