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
typeMyType={arguments: Array<string>}functionmyFunction(myType: MyType){for(leti=0;i<10;i++){console.log(myType.arguments[i]);// create closure so that tsc will turn loop body into functionconstx=5;[1,2,3].forEach(function(j){console.log(x);})}}export{myFunction};
Expected behavior:
myType.arguments[i] is left unmodified or translated to something equivalent
"use strict";functionmyFunction(myType){var_loop_1=function(i){console.log(myType.arguments_1[i]);// create closure so that tsc will turn loop body into functionvarx=5;[1,2,3].forEach(function(j){console.log(x);});};vararguments_1=arguments;for(vari=0;i<10;i++){_loop_1(i);}}exports.myFunction=myFunction;
ES5 permits keywords to be used as object properties.
If in aspiring to be a superset of javascript, typescript also wants to allow keywords to be used as object properties, then myType.arguments[i] should stay unchanged or become something equivalent. If not, then typescript should raise an error. Currently no error is raised, and incorrect javascript is generated.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.1.5
Code
Expected behavior:
myType.arguments[i]
is left unmodified or translated to something equivalentActual behavior:
myType.arguments[i]
becomesmyType.arguments_1[i]
.ES5 permits keywords to be used as object properties.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Reserved_word_usage
If in aspiring to be a superset of javascript, typescript also wants to allow keywords to be used as object properties, then
myType.arguments[i]
should stay unchanged or become something equivalent. If not, then typescript should raise an error. Currently no error is raised, and incorrect javascript is generated.The text was updated successfully, but these errors were encountered: