-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeBugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
With the following tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "amd"
}
}The following file:
if( true ) {
function foo() {}
}
export = foo;Compiles with no errors or warnings, and emits:
define(["require", "exports"], function (require, exports) {
"use strict";
if (true) {
function foo() {
}
}
return foo;
});This, however, results in a runtime error in Firefox, because in strict mode, function declarations may not appear within if blocks.
I believe this should cause a compiler error, or at very least, a warning.
This caused an issue on our production website today. When we updated our TypeScript compiler, our code, which was working without "use strict", stopped working (without any warning or build issues). I'm currently trying to make sure nothing else broke because of "use strict", but the lack of warnings makes finding these issues difficult.
Metadata
Metadata
Assignees
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeBugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue