Vedant Roy aea0fcd599
Correctly transpile when cross-param refs with obj rest (#11326)
* Transform initializers with ids in rest elements

Fix issue 11281. Transform parameters with default initializers that
have ids that are also in a parameter with a rest element.
Before, these parameters were not transformed.

* Add plugin-transform-parameters as dependency

* Remove outdated comment

* Use set instead of array for paramsWithRestElement

* Skip when encounter "Scope"

Previously, f({...R}, f = R => R) would be incorrectly transformed.

* Pass in loose mode option instead of false

* Address review and re-organize tests

Checking the RHS of an assignment pattern/checking the parent of
an identifier node fails on cases like "({...R}, a = f(R))" or
"({...R}, {[R.key]: a = 42})".

Also refactor tests by removing unecessary tests and
separating "should transform" from "should not transform" tests.
2020-04-07 21:06:43 +02:00

10 lines
256 B
JavaScript

({...R}, a = R) => {}
({X: Y,...R}, {a = {Y}}) => {}
(a = R, {...R}) => {}
({...R}, e, c = 2, a = R, f = q) => { let q; }
({...R}, a = f(R)) => {}
({...R}, { [R.key]: a = 42 }) => {}
({...R}, {a = {R: b}}) => {}
({...R}, {a = R => R} = {b: R => R}) => {}