💻
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
REPL
(() => {
var A = 'hello';
enum Foo {
A = 1,
B = A, // A is resolved to the enum member if it's constant
}
})();
(() => {
var A = 'hello';
enum Bar {
A = Math.random(),
B = A, // Otherwise, A is resolved to the outer scope's binding
}
})();
enum Baz {
A = Math.random(),
B = A, // If there's no outer scope's binding, it's again resolved to the enum member
}
Configuration file name
No response
Configuration
No response
Current and expected behavior
The current behavior is commented in the input code.
I would expect the enum transformation to follow what tsc does (which is more consistent and simpler): https://www.typescriptlang.org/play/?#code/PTAEEFQSwZ1BDANgd3gTzgJwKYwPaIBu2AJqAC54UAW2o2AdgK4C2oL2LARtpgHQAoIQAphASlABeAHygA3gNChC8TBCmgA5AHNEeLkk0BuRfWZsAYnioKlSyJNABGADSmlAIQ3gXoUwF8BfzFxEwFRCRl5UxU1By1dfUMTJUZWUA9VaLt1RwBZeHJqPkx4BhI8FnE3HK9HHwCgkLEwgTS2TIAvbNzQAqKSsoqqsRqM7zdAoA
Environment
Babel v7.26.4
@babel/plugin-transform-typescript v7.26.3
Possible solution
No response
Additional context
No response
💻
How are you using Babel?
Programmatic API (
babel.transform,babel.parse)Input code
REPL
Configuration file name
No response
Configuration
No response
Current and expected behavior
The current behavior is commented in the input code.
I would expect the enum transformation to follow what tsc does (which is more consistent and simpler): https://www.typescriptlang.org/play/?#code/PTAEEFQSwZ1BDANgd3gTzgJwKYwPaIBu2AJqAC54UAW2o2AdgK4C2oL2LARtpgHQAoIQAphASlABeAHygA3gNChC8TBCmgA5AHNEeLkk0BuRfWZsAYnioKlSyJNABGADSmlAIQ3gXoUwF8BfzFxEwFRCRl5UxU1By1dfUMTJUZWUA9VaLt1RwBZeHJqPkx4BhI8FnE3HK9HHwCgkLEwgTS2TIAvbNzQAqKSsoqqsRqM7zdAoA
Environment
Babel v7.26.4
@babel/plugin-transform-typescript v7.26.3
Possible solution
No response
Additional context
No response