You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior:
When targeting ES5, an object declared like so: {arguments: "foo"}
is emitted to javascript as: {arguments: "foo"}
Actual behavior:
The object is emitted to javascript as: {arguments_1: "foo"}
See below code sample for more related bugs.
Related Issues:
A similar variant was reported and correctly fixed here: #13586
This exact bug was previously reported here, and closed as "fixed" by the reporter. (I don't think it was actually fixed though). #33540
Code
// Compile with ES5 targetfunctionmyFunc(_param: string){for(letx=0;x<1;++x){leti : number;// It's essential to have an inner function declared that references a variable defined in the loop[].forEach(function(){i})letbrokenObj1={arguments: 0}// Actual: {"arguments_1":0}// Expected: {"arguments":0}console.log(JSON.stringify(brokenObj1));letbrokenObj2={
arguments
}// Actual: {"arguments":{"0":0}}// Expected: {"arguments":{"0":"paramValue"}}// (Becuase it erroneously references the arguments of the generated loop function `_loop_1`)console.log(JSON.stringify(brokenObj2));letbrokenObj3={arguments: arguments}// Actual: {"arguments_1":{"0":"paramValue"}}// Expected: {"arguments":{"0":"paramValue"}}console.log(JSON.stringify(brokenObj3));}}myFunc("paramValue");
Output
"use strict";// Compile with ES5 targetfunctionmyFunc(_param){var_loop_1=function(x){vari;// It's essential to have an inner function declared that references a variable defined in the loop[].forEach(function(){i;});varbrokenObj1={arguments_1: 0};// Actual: {"arguments_1":0}// Expected: {"arguments":0}console.log(JSON.stringify(brokenObj1));varbrokenObj2={arguments: arguments};// Actual: {"arguments":{"0":0}}// Expected: {"arguments":{"0":"paramValue"}}// (Becuase it erroneously references the arguments of the generated loop function `_loop_1`)console.log(JSON.stringify(brokenObj2));varbrokenObj3={arguments_1: arguments_1};// Actual: {"arguments_1":{"0":"paramValue"}}// Expected: {"arguments":{"0":"paramValue"}}console.log(JSON.stringify(brokenObj3));};vararguments_1=arguments;for(varx=0;x<1;++x){_loop_1(x);}}myFunc("paramValue");
Two problems are fixed:
* `isArgumentsLocalBinding` did only `PropertyAccessExpression`, now
it's also doing `PropertyAssignment` (doesn't affect other files,
since it's only used in the emitter).
* `visitShorthandPropertyAssignment` should call `visitIdentifier` on
the synthesized id. (For completion it might be better to make it
visit the the original?)
Fixesmicrosoft#38594.
Two problems are fixed:
* `isArgumentsLocalBinding` did only `PropertyAccessExpression`, now
it's also doing `PropertyAssignment` (doesn't affect other files,
since it's only used in the emitter).
* `visitShorthandPropertyAssignment` should call `visitIdentifier` on
the synthesized id. (For completion it might be better to make it
visit the the original?)
Fixesmicrosoft#38594.
Two problems are fixed:
* `isArgumentsLocalBinding` did only `PropertyAccessExpression`, now
it's also doing `PropertyAssignment` (doesn't affect other files,
since it's only used in the emitter).
* `visitShorthandPropertyAssignment` should call `visitIdentifier` on
the synthesized id. (For completion it might be better to make it
visit the the original?)
Fixes#38594.
TypeScript Version: Nightly (also, 3.9.2, 3.7.4, and probably others)
Search Terms:
arguments property, arguments_1 renamed
Expected behavior:
When targeting ES5, an object declared like so:
{arguments: "foo"}
is emitted to javascript as:
{arguments: "foo"}
Actual behavior:
The object is emitted to javascript as:
{arguments_1: "foo"}
See below code sample for more related bugs.
Related Issues:
A similar variant was reported and correctly fixed here:
#13586
This exact bug was previously reported here, and closed as "fixed" by the reporter. (I don't think it was actually fixed though).
#33540
Code
Output
Compiler Options
Playground Link: Provided
P.S. Typescript is awesome. We ❤️Typescript!
The text was updated successfully, but these errors were encountered: