microsoft / microsoft/TypeScript
`export` modifier on `enum` disables `This condition will always return * ts2845`
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
### 🔎 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_
Contributor guide
Research direction
Start by reproducing the linked TypeScript Playground case, then compare the diagnostic behavior with and without the `export` modifier on `AdapterOutputType`. Trace the type-checking path for the enum member comparison and verify that the erroneous condition receives TS2845 without introducing a diagnostic for the valid case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 56/100