microsoft / microsoft/TypeScript
`export` modifier on `enum` disables `This condition will always return * ts2845`
- 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
export enum ts2845
### 🕗 Version & Regression Information
5.4 doesn't flag it without the `export` modifier either.
### ⏯ Playground Link
https://www.typescriptlang.org/play/?target=99&module=0&ts=6.0.0-dev.20260416#code/KYDwDg9gTgLgBMAdgVwLZwIIBMCGYbBQDyyMYpAKgJ5jBwDeAUHJgAqsD6rGA4gKIAaZnG78AykIC+jRlmABjADY4odeREQBneDBrAAXJlz5CJMpT0z1W+AGsAloixwAvMN21XLl0bwFipOQw1LQAdBjsXLx8cAA+sb4mAebBeqGifGLCLAD0OSwFhUXFJaUUABb2mnDWWPYw9hpwAO72iopwOIrNOFTVqjDIUIhwAOQwUMjAo6EAFABMABwALACsAJTZcAD8Y4rAAGYwo1uGo1D2AOblxwDcQA
### 💻 Code
```ts
// remove `export` modifier
export enum AdapterOutputType {
APP_PAGE,
PAGES,
}
declare const type: AdapterOutputType
const kind =
type === AdapterOutputType.APP_PAGE || AdapterOutputType.PAGES
// ~ should be flagged with: This condition will always return 'true'.(2845)
? 'left'
: 'right';
```
### 🙁 Actual behavior
No typechecking error
### 🙂 Expected behavior
`ts2845` because the condition is always `true`.
### Additional information about the issue
_No response_
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện trường hợp TypeScript Playground được liên kết, sau đó so sánh hành vi chẩn đoán khi có và không có bộ sửa đổi `export` trên `AdapterOutputType`. Truy vết đường dẫn kiểm tra kiểu cho phép so sánh thành viên enum và xác minh rằng điều kiện sai nhận TS2845 mà không đưa ra chẩn đoán cho trường hợp hợp lệ.
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
- compilers
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 56/100