dillon1000/react
Commit
Browse files Support AssignmentPattern (default values in destructuring)
"Supports" default values in destructuring (AssignmentPattern) by lowering to a
ternary, even in the output. Examples:
```javascript
// Input:
const [x = 'default'] = y;
// Output:
const [t0] = y;
const x = t0 === undefined ? 'default' : t0;
```
```javascript
// Input 2
const [{x} = makeObject()] = y;
// Output 2
const [t0] = y;
const {x} = t0 === undefined ? makeObject() : t0;
```
Note that this is how Babel lowers AssignmentPattern, so it isn't too bad. This
should help avoid the need to update product code, even if the output isn't
perfectly ideal.Changed paths8 files
First-parent comparisoncompiler/forget/src/HIR/BuildHIR.ts ModifiedA compiler/forget/src/__tests__/fixtures/compiler/destructuring-array-default.expect.md AddedA compiler/forget/src/__tests__/fixtures/compiler/destructuring-array-default.js AddedA compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment-array-default.expect.md AddedA compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment-array-default.js AddedA compiler/forget/src/__tests__/fixtures/compiler/destructuring-object-default.expect.md AddedA compiler/forget/src/__tests__/fixtures/compiler/destructuring-object-default.js AddedM compiler/forget/src/__tests__/fixtures/compiler/error.todo-kitchensink.expect.md ModifiedPatch
Files changed
Rendering syntax-highlighted changes…