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
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
### 🔎 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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện ví dụ const enum được cung cấp bằng tsc ở chế độ watch, trước tiên chuyển đổi isolatedModules rồi preserveConstEnums trong tsconfig.json. So sánh đầu ra được emit với một lần biên dịch mới, sau đó lần theo cấu hình của chế độ watch và các đường dẫn invalidation của việc emit. Hoàn thành khi việc thay đổi isolatedModules khiến const enums được emit lại mà không cần khởi động lại hoàn toàn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- build-system, compilers
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 38/100