#3840·babel

Merged Rest and Spread operation (T6782)

Author: babel-botCreated Dec 7, 2015Updated Sep 2, 2026
Labelsarea: perfi: discussionhelp wantedclaimedSpec: Object Rest/Spread

Issue originally made by @sebmarkbage

Description

It is plausible that rest/spread operations can be optimized to be merged into a single operations if there are no side-effects between them. E.g. this:

let { a, b, ...rest } = obj;
let abc = { ...rest, c: 123 };

can be optimized to this:

let abc = combinedRestSpread(/*copied*/ obj, /*new object*/ { c: 123 }, /*excluded names*/ ['a', 'b']);