babel: [Bug]: `Cannot set properties of undefined (setting 'identifier')` error when using `plugin-proposal-decorators` legacy with `plugin-transform-block-scoping`
💻
- Would you like to work on a fix?
How are you using Babel?
Input code
try {
class C {
@Dummy foo() {
throw new Error();
}
}
let c = new C();
c.foo();
} catch (e) {
console.error(e);
}
Configuration file name
.babelrc
Configuration
{
//"presets": [
// ["@babel/preset-env", {"targets": "firefox 50"}]
//],
"plugins": [
["@babel/plugin-proposal-decorators", {"legacy": true}],
["@babel/transform-block-scoping"]
]
}
Current and expected behavior
Current:
TypeError: /Users/chsuh/decorators-bug/index.js: Cannot set properties of undefined (setting 'identifier')
at PluginPass.ClassDeclaration (/Users/chsuh/decorators-bug/node_modules/@babel/plugin-proposal-decorators/lib/transformer-legacy.js:148:26)
at newFn (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/visitors.js:159:21)
at NodePath._call (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/path/context.js:46:20)
at NodePath.call (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/path/context.js:36:17)
at NodePath.visit (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/path/context.js:84:31)
at TraversalContext.visitQueue (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/context.js:96:16)
at TraversalContext.visitMultiple (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/context.js:67:17)
at TraversalContext.visit (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/context.js:119:19)
at traverseNode (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
at NodePath.visit (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/path/context.js:90:52) {
code: 'BABEL_TRANSFORM_ERROR'
}
Environment
System: OS: macOS 13.1 Binaries: Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm npmPackages: @babel/cli: ^7.19.3 => 7.19.3 @babel/plugin-proposal-decorators: ^7.20.5 => 7.20.5 @babel/plugin-transform-block-scoping: ^7.20.5 => 7.20.5
Possible solution
No response
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (9 by maintainers)
@nicolo-ribaudo thanks. With
@babel/plugin-transform-block-scoping@7.20.9
issue was resolved in our case