v1.0.2
Patch Changes
-
bd5e331: Fix elimination for object patterns and array patterns
Previously, running dead code elimination on object patterns and array patterns (aka destructuring) was brittle.
For example:const { a: { b: c }, } = z console.log(c)
Dead code elimination used to incorrectly remove the entire variable declaration even though
cis referenced:-const { - a: { b: c }, -} = z console.log(c);
This was caused by erroneous detection of
aandbas unreferenced variables.
Butaandbare not variables, they are object property keys.
Onlycis a variable and it is referenced.This is now corrected so that variables in object patterns and array patterns are detected only within values of object properties.
This also correctly accounts for cases where the key and value are the same for example{ a }.