-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed as not planned
Labels
Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
The TypeScript compiler generates the following code for rest arguments:
function foo(x, y, z, ...rest) {
return;
}
function foo(x, y, z) {
var rest = [];
for (var i = 0; i < arguments.length - 3; i++) {
rest[i] = arguments[i + 3];
}
return;
}
Although rest
is unused in the body of the function, JS engines can't easily dead code eliminate the allocation of the rest
array and the subsequent for loop due to the possibility of Array.prototype being mutated:
Object.defineProperty(Array.prototype, 42, { set: function() { alert(this[41]); }});
It's much easier for the TypeScript compiler to avoid emitting this code when it is not necessary.
See more details:
Metadata
Metadata
Assignees
Labels
Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript