-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Optimize rest arguments. #498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note that you can work around this by writing: function foo(x, y, z);
function foo(x, y, z, ...rest) {
return;
} |
@RyanCavanaugh How does the extra declaration remove the codegen for the rest array processing and why would that not be a bug in itself? P.S., the Playground currently generates the same code with or without the extra declaration. |
Typo, I meant to write this: function foo(x, y, z, ...rest);
function foo(x, y, z) {
return;
} |
Just a reminder, #518 fixes this issue. When will it get merged into master? |
This doesn't really seem needed - the overload trick is sufficient, and most people are not downleveling rest args anymore. |
The TypeScript compiler generates the following code for rest arguments:
Although
rest
is unused in the body of the function, JS engines can't easily dead code eliminate the allocation of therest
array and the subsequent for loop due to the possibility of Array.prototype being mutated:It's much easier for the TypeScript compiler to avoid emitting this code when it is not necessary.
See more details:
https://bugzilla.mozilla.org/show_bug.cgi?id=1056446
The text was updated successfully, but these errors were encountered: