However, when I recreate the AST and recast that, the result is
function HelloWorld({ name }) {
...
}
which seems incorrect for this case.
If I omit the shorthand: true, the result is:
function HelloWorld({ name: name = 'luna' }) {
...
}
which is correct, but not ideal.
I'm not sure if I'm missing something. Is there a way to get the "shorthand" version of default parameters when you destructure a function parameter that is an object?
Hey, I'm trying to use
jscodeshift
to create this pattern:The object property looks like the following when this is translated to an AST:
However, when I recreate the AST and recast that, the result is
which seems incorrect for this case.
If I omit the
shorthand: true
, the result is:which is correct, but not ideal.
I'm not sure if I'm missing something. Is there a way to get the "shorthand" version of default parameters when you destructure a function parameter that is an object?