-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
Feature Request
In the docs, it says that:
Does not support
const enums because those require type information to compile.
I don't believe that this is true. Babel should be able to transpile const enums into objects, which will achieve the same functionality as typescript, through different transpiled output.
Given this code:
const enum Direction { Left, Right, Down, Up }
console.log(Direction.Down)tsc would compile this to:
console.log(2)I propose that Babel compiles the enum to:
const Direction = {
Left: 0,
Right: 1,
Down: 2,
Up: 3
}
console.log(Direction.Down)Which functions the same as the tsc output.
A minifier like terser/uglify is able to transpile that output ☝️ to the same as the tsc output.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue