Skip to content

minifier: remove unused declarator in destructuring declaration #17349

@sapphi-red

Description

@sapphi-red
// input (assuming a* is not used)
let [a1, b1] = [0, 1];
let { a2, b2 } = { a2: 0, b2: 1 };
let [a3, b3] = c3;
let { a4, b4 } = c4;
let [a5] = [0];
let { a6 } = { a6: 0 };
let [b71, { a7, b72 }] = [0, { a7: 1, b72: 2 }];

// output
let [, b1] = [0, 1];
let { b2 } = { a2: 0, b2: 1 };
let [a3, b3] = c3; // keep it as-is because we don't know about c3
let { a4, b4 } = c4; // keep it as-is because we don't know about c4
// remove a5 completely as all declarator is removed
// remove a6 completely as all declarator is removed
let [b71, { b72 }] = [0, { a7: 1, b72: 2 }];

refs #16580

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions