-
-
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
When using the typescript compiler, there is an option to "preserve const enums", which essentially just treats const enums exactly the same as non-const enums. It would be really useful to have the same feature in the babel transform.
Input Code
export const enum E {
A = 1
}Babel Configuration (.babelrc, package.json, cli command)
{
"plugins": [
["transform-typescript", {"preserveConstEnums": true}]
]
}Expected Behavior
export let E;
(function (E) {
E[E["A"] = 1] = "A";
})(E || (E = {}));Current Behavior
Throws: 'const' enums are not supported
Possible Solution
Add an option that makes const enums behave exactly the same as regular enums.
Context
I want to be able to use babel to transform my typescript in development, as this will be much faster than doing a babel pass and a typescript pass, and babel is needed for other plugins. In production, I can use the slower typescript transform, which handles const enums properly.
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