Report error for block scope function declaration in ES5

This commit is contained in:
Sheetal Nandi
2016-04-11 12:04:55 -07:00
parent 6988a0a479
commit 593dc2bc9f
3 changed files with 46 additions and 1 deletions

View File

@@ -1,10 +1,13 @@
tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts(3,14): error TS1250: In ES5 or lower, function declarations are not allowed in block scope in strict mode.
tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts(6,1): error TS2304: Cannot find name 'foo'.
==== tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts (1 errors) ====
==== tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts (2 errors) ====
"use strict";
if (true) {
function foo() { } // Error to declare function in block scope
~~~
!!! error TS1250: In ES5 or lower, function declarations are not allowed in block scope in strict mode.
foo(); // This call should be ok
}
foo(); // Error to find name foo