@babel/traverse noScope can't path.remove()
See original GitHub issueWhen I upgraded from v7.7.7 to v7.8.4, I found that there was a problem with the noScope option of @babel/traverse.
Error message:
e:\mypath\babel\node_modules\@babel\traverse\lib\path\removal.js:39
Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
^
TypeError: Cannot read property 'removeBinding' of null
at e:\mypath\babel\node_modules\@babel\traverse\lib\path\removal.js:39:52
at Array.forEach (<anonymous>)
at NodePath._removeFromScope (e:\mypath\babel\node_modules\@babel\traverse\lib\path\removal.js:39:25)
at NodePath.remove (e:\mypath\babel\node_modules\@babel\traverse\lib\path\removal.js:22:8)
at AssignmentExpression (e:\mypath\babel\test.js:6:14)
at NodePath._call (e:\mypath\babel\node_modules\@babel\traverse\lib\path\context.js:55:20)
at NodePath.call (e:\mypath\babel\node_modules\@babel\traverse\lib\path\context.js:42:17)
at NodePath.visit (e:\mypath\babel\node_modules\@babel\traverse\lib\path\context.js:90:31)
at TraversalContext.visitQueue (e:\mypath\babel\node_modules\@babel\traverse\lib\context.js:112:16)
at TraversalContext.visitSingle (e:\mypath\babel\node_modules\@babel\traverse\lib\context.js:84:19)
Code to reproduce the problem:
var traverse = require("@babel/traverse").default;
var parser = require("@babel/parser");
traverse(parser.parse("a=1"), {
AssignmentExpression(path) {
path.remove();
},
noScope: true,
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Top 5 babel-traverse Code Examples - Snyk
Learn more about how to use babel-traverse, based on babel-traverse code examples created from the most popular ways it is used in public...
Read more >Babel traverse to the first JSXElement - Stack Overflow
So I found the answer by pure luck. I should have added in a stop() immediately after traversing the JSXElement
Read more >Options - Babel.js
Defaults to searching for a default babel.config.json file, but can be passed the path of any JS or JSON5 config file. NOTE: This...
Read more >Babel-plugin-handbook - npm.io
Note: Some properties have been removed for simplicity. Each of these are known as a Node. An AST can be made up of...
Read more >升级至 Babel 7 (API)
Calls to babel.transform or any other transform function may return null if the ... Removed path.mark() since we didn't use it and it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@JLHwung The issue was resolved by modifying our code 😛
@liuxingbaoyu Do you want to open a PR?
Ok, it’s not a problem!