Closed
Description
Code
var _b;
class C {
static properties: { [key: string]: string } = {
["foo"] : "bar1",
};
static otherproperties = (_b = {}, _b["foo"] = "bar2", _b);
}
// Use C
console.log(C.properties["foo"] + " " + C.otherproperties["foo"])
// End of original src
Expected behavior:
I would have expected that the sugar/javascript for constructing 'properties' would have declared the tmp variable before the construction. In the compile js the _a is declared after the last expression (but before that last comment??).
Google closure compiler warns about this.
Actual behavior:
var _b;
var C = (function () {
function C() {
}
return C;
}());
C.properties = (_a = {},
_a["foo"] = "bar1",
_a);
C.otherproperties = (_b = {}, _b["foo"] = "bar2", _b);
// Use C
console.log(C.properties["foo"] + " " + C.otherproperties["foo"]);
var _a;
// End of original src
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
ahejlsberg commentedon Apr 24, 2017
See #4138 and #7297.
peblpebl commentedon Apr 24, 2017
This issue is better explained in #4138.
peblpebl commentedon Apr 24, 2017
Hmm, this is not quite the same.
In #4138 and #7397 the declaration is in a function and if I understand ecma script correct - then valid everywhere within that function.
_a is not declared in a function here?
RyanCavanaugh commentedon Apr 24, 2017
It doesn't matter. All
var
declarations are hoisted to the top of their enclosing lexical scopemhegazy commentedon May 8, 2017
This issue seems to have been already addressed or is unactionable at the moment. I am auto-closing it for now.