Constant folding is not working inside `const enum`
- Dominant language
- Go
- Stars
- 40.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
```ts
const enum First {
A = 1,
B = 2,
C = 3
}
const multiplier = 5
const enum Second {
D = First.A * multiplier,
E = First.B * multiplier,
F = First.C * multiplier
}
console.log(Second.E + Second.F)
```
`bunx esbuild --minify 1.ts`
### Expected output
`console.log(25);`
### Actual output
`"use strict";(()=>{var m=5,u=(l=>(l[l.D=1*m]="D",l[l.E=2*m]="E",l[l.F=3*m]="F",l))(u||{});console.log(u.E+u.F);})();`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the reported `bunx esbuild --minify 1.ts` reproduction and compare its output with the expected `console.log(25);`. Trace the TypeScript `const enum` handling and constant-folding path; done means the example is folded to the expected output without changing unrelated enum behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100