AST-query icon indicating copy to clipboard operation
AST-query copied to clipboard

Question: Adding an element to a shorthand object

Open duro opened this issue 8 years ago • 1 comments

I am trying to edit a file that has a block like this

const reducers = combineReducers({
    app,
    home
});

I have been able to add a new key to it using this command:

tree.callExpression('combineReducers').arguments.at(0).key('test').value('test')

This ends up creating code like this:

const reducers = combineReducers({
    app,
    home,
    test: test
});

How can I get it to result in this??:

const reducers = combineReducers({
    app,
    home,
    test
});

duro avatar Dec 29 '16 05:12 duro

Do you know what is the AST tree of the desired syntax?

SBoudrias avatar Dec 29 '16 12:12 SBoudrias