I'm trying to take something like var a = 5;
and transpile it to something like thing.a = 5
.
Using this code below in my visitor, it tells me unexpected token .
VariableDeclarator: {
enter: function (path, state) {
path.replaceWith(
t.assignmentExpression(
'=',
t.memberExpression(
t.identifier('abc'),
t.identifier('def')
),
t.stringLiteral('xyz')
)
)
}
}
What am I not taking into account here?
What's the canonical way to accomplish this?