Within my TypeScript code, I have a simple class named Foo as part of the Test module.
module Test {
"use strict";
class Foo {
public static name = "foo";
}
}
However, when I attempt to run this code in Chrome, an error occurs:
I receive an Uncaught TypeError: Cannot assign to read only property 'name' of function 'function Foo() { }'
Upon inspecting the generated JavaScript, here is what it looks like:
var Test;
(function (Test) {
"use strict";
var Foo = (function () {
function Foo() {
}
Foo.name = "foo";
return Foo;
}());
})(Test || (Test = {}));
If I change the variable name from `name` to something else like `huh`, the error disappears:
module Test {
"use strict";
class Foo {
public static huh = "foo";
}
}
Why does using the name `name` lead to this issue?