Out of the blue, it seems like my VS17 has started transpiling my TypeScript to ECMAScript 6, but now VS is not accepting it and throwing a bunch of SCRIPT1002 and SCRIPT1006 errors suddenly: "JavaScript critical error at line 3, column 5 in http://localhost:57125/Scripts/js/Modules/Test.js\n\nSCRIPT1002: Syntax error"
This is the simplified TS module I have:
module Test {
export class TestObject {
Data: string;
}
}
It gets transpiled to
var Test;
(function (Test) {
class TestObject {
}
Test.TestObject = TestObject;
})(Test || (Test = {}));
//# sourceMappingURL=Test.js.map
However, Visual Studio is flagging class
as a syntactical error.
What it should be generating (and was doing so until recently) is
var Test;
(function (Test) {
var TestObject = (function () {
function TestObject() {
}
return TestObject;
}());
Test.TestObject = TestObject;
})(Test || (Test = {}));
I suspect that VS (or maybe IE11?) is expecting ECMAScript 5, but changing the version in the project settings isn't helping (tried ECMAScript 3, 5, 6, 2016, 2017, and Next). I have TS 2.8, 3.0, and 3.1 installed, but switching between them doesn't solve the issue. The module system is set to AMD, yet this hasn't made any difference for me either...
Any suggestions on how to resolve this? I've rebooted VS multiple times and even restarted my computer just in case some rogue process was causing the problem.