question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@babel/traverse noScope can't path.remove()

See original GitHub issue

When 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:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolo-ribaudocommented, Feb 12, 2020

@JLHwung The issue was resolved by modifying our code 😛

@liuxingbaoyu Do you want to open a PR?

1reaction
nicolo-ribaudocommented, Feb 11, 2020

Ok, it’s not a problem!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found