Skip to content

delete() seems not to work in particular cases #28

Description

@topheroes

Hello,

Node 17.0.1, code:

const { refactor } = require('shift-refactor');


const code = '! function(a,b,c){ a = 1, b = 2, c = 3, console.log(200)}()';
const secondExpression = "Script > ExpressionStatement > UnaryExpression > CallExpression > FunctionExpression > FunctionBody > ExpressionStatement > .expression > .left > .left > .right";

const fs = require("fs");

var $script = refactor(code);


$script(secondExpression).delete();


console.log($script.print());

Shows error:

_\node_modules\shift-reducer\dist\director.js:68
return reducer.reduceBinaryExpression(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right) });
^

TypeError: Cannot read properties of null (reading 'type')_

Am I doing anything wrong? Please advise.

PS. Thank you for your great videos, hope you'll continue to make them someday.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions