-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
outdatedA 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 issuepkg: traverse
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
import * as types from '@babel/types';
import traverse from '@babel/traverse';
import {parse} from '@babel/parser';
const ast = parse(`[
'/',
'/hello.md'
];`);
const {ArrayExpression, ObjectExpression, StringLiteral} = types;
const array = ArrayExpression([]);
const str = StringLiteral('x');
array.elements.push(str);
traverse(array, {
noScope: true,
StringLiteral(path) {
path.remove();
}
});Configuration file name
No response
Configuration
No response
Current and expected behavior
file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:3787
if (parent.isSequenceExpression() && parent.node.expressions.length === 1) {
^
TypeError: Cannot read properties of null (reading 'isSequenceExpression')
at hooks (file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:3787:14)
at NodePath._callRemovalHooks (file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:3833:9)
at NodePath.remove (file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:3819:12)
at StringLiteral (file:///Users/coderaiser/putout-babel/lib/index.mjs:31:14)
at NodePath._call (file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:3582:20)
at NodePath.call (file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:3572:17)
at NodePath.visit (file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:3616:31)
at TraversalContext.visitQueue (file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:4862:16)
at TraversalContext.visitMultiple (file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:4837:17)
at TraversalContext.visit (file:///Users/coderaiser/putout-babel/node_modules/@babel/traverse/lib/index.js:4883:19)
Node.js v20.10.0
Environment
node -v 20
babel 8.aplpha-5
Possible solution
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
outdatedA 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 issuepkg: traverse