Object Destructuring with Default Parameter for Function Declaration Shorthand
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 194
- Avg merge
- 22h 43m
- Merged PRs (30d)
- 10
Description
Hey, I'm trying to use `jscodeshift` to create this pattern:
```
function HelloWorld({ name = 'luna' }) {
...
}
```
The object property looks like the following when this is translated to an AST:
```
{
type: 'Property'
shorthand: true,
key: {
type: 'Identifier',
name: 'name',
...
},
value: {
type: 'AssignmentPattern',
...
},
}
```
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?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.