diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationES5.js b/tests/baselines/reference/blockScopedFunctionDeclarationES5.js new file mode 100644 index 00000000000..066dd07351c --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationES5.js @@ -0,0 +1,13 @@ +//// [blockScopedFunctionDeclarationES5.ts] +if (true) { + function foo() { } + foo(); +} +foo(); + +//// [blockScopedFunctionDeclarationES5.js] +if (true) { + function foo() { } + foo(); +} +foo(); diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationES5.symbols b/tests/baselines/reference/blockScopedFunctionDeclarationES5.symbols new file mode 100644 index 00000000000..5c8f82cf0ff --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationES5.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationES5.ts === +if (true) { + function foo() { } +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationES5.ts, 0, 11)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationES5.ts, 0, 11)) +} +foo(); +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationES5.ts, 0, 11)) + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationES5.types b/tests/baselines/reference/blockScopedFunctionDeclarationES5.types new file mode 100644 index 00000000000..b3c4d9b7d73 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationES5.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationES5.ts === +if (true) { +>true : boolean + + function foo() { } +>foo : () => void + + foo(); +>foo() : void +>foo : () => void +} +foo(); +>foo() : void +>foo : () => void + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationES6.js b/tests/baselines/reference/blockScopedFunctionDeclarationES6.js new file mode 100644 index 00000000000..32450cd66f1 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationES6.js @@ -0,0 +1,13 @@ +//// [blockScopedFunctionDeclarationES6.ts] +if (true) { + function foo() { } + foo(); +} +foo(); + +//// [blockScopedFunctionDeclarationES6.js] +if (true) { + function foo() { } + foo(); +} +foo(); diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationES6.symbols b/tests/baselines/reference/blockScopedFunctionDeclarationES6.symbols new file mode 100644 index 00000000000..65fb133b446 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationES6.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationES6.ts === +if (true) { + function foo() { } +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationES6.ts, 0, 11)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationES6.ts, 0, 11)) +} +foo(); +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationES6.ts, 0, 11)) + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationES6.types b/tests/baselines/reference/blockScopedFunctionDeclarationES6.types new file mode 100644 index 00000000000..7ab74feb0ed --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationES6.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationES6.ts === +if (true) { +>true : boolean + + function foo() { } +>foo : () => void + + foo(); +>foo() : void +>foo : () => void +} +foo(); +>foo() : void +>foo : () => void + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.js b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.js new file mode 100644 index 00000000000..f0926cadf39 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.js @@ -0,0 +1,15 @@ +//// [blockScopedFunctionDeclarationStrictES5.ts] +"use strict"; +if (true) { + function foo() { } // Error to declare function in block scope + foo(); // This call should be ok +} +foo(); // Error to find name foo + +//// [blockScopedFunctionDeclarationStrictES5.js] +"use strict"; +if (true) { + function foo() { } // Error to declare function in block scope + foo(); // This call should be ok +} +foo(); // Error to find name foo diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.symbols b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.symbols new file mode 100644 index 00000000000..b29ea10c205 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts === +"use strict"; +if (true) { + function foo() { } // Error to declare function in block scope +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES5.ts, 1, 11)) + + foo(); // This call should be ok +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES5.ts, 1, 11)) +} +foo(); // Error to find name foo +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES5.ts, 1, 11)) + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.types b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.types new file mode 100644 index 00000000000..94a61fc99af --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts === +"use strict"; +>"use strict" : string + +if (true) { +>true : boolean + + function foo() { } // Error to declare function in block scope +>foo : () => void + + foo(); // This call should be ok +>foo() : void +>foo : () => void +} +foo(); // Error to find name foo +>foo() : void +>foo : () => void + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.js b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.js new file mode 100644 index 00000000000..0a1b263875b --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.js @@ -0,0 +1,15 @@ +//// [blockScopedFunctionDeclarationStrictES6.ts] +"use strict"; +if (true) { + function foo() { } // Allowed to declare block scope function + foo(); // This call should be ok +} +foo(); // Cannot find name since foo is block scoped + +//// [blockScopedFunctionDeclarationStrictES6.js] +"use strict"; +if (true) { + function foo() { } // Allowed to declare block scope function + foo(); // This call should be ok +} +foo(); // Cannot find name since foo is block scoped diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.symbols b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.symbols new file mode 100644 index 00000000000..af53145d3f2 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationStrictES6.ts === +"use strict"; +if (true) { + function foo() { } // Allowed to declare block scope function +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES6.ts, 1, 11)) + + foo(); // This call should be ok +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES6.ts, 1, 11)) +} +foo(); // Cannot find name since foo is block scoped +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES6.ts, 1, 11)) + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.types b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.types new file mode 100644 index 00000000000..2149b75f871 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationStrictES6.ts === +"use strict"; +>"use strict" : string + +if (true) { +>true : boolean + + function foo() { } // Allowed to declare block scope function +>foo : () => void + + foo(); // This call should be ok +>foo() : void +>foo : () => void +} +foo(); // Cannot find name since foo is block scoped +>foo() : void +>foo : () => void + diff --git a/tests/cases/compiler/blockScopedFunctionDeclarationES5.ts b/tests/cases/compiler/blockScopedFunctionDeclarationES5.ts new file mode 100644 index 00000000000..dbb725361a0 --- /dev/null +++ b/tests/cases/compiler/blockScopedFunctionDeclarationES5.ts @@ -0,0 +1,6 @@ +// @target: ES5 +if (true) { + function foo() { } + foo(); +} +foo(); \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedFunctionDeclarationES6.ts b/tests/cases/compiler/blockScopedFunctionDeclarationES6.ts new file mode 100644 index 00000000000..fd0e678b806 --- /dev/null +++ b/tests/cases/compiler/blockScopedFunctionDeclarationES6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +if (true) { + function foo() { } + foo(); +} +foo(); \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts b/tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts new file mode 100644 index 00000000000..c5035e1130c --- /dev/null +++ b/tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts @@ -0,0 +1,7 @@ +// @target: ES5 +"use strict"; +if (true) { + function foo() { } // Error to declare function in block scope + foo(); // This call should be ok +} +foo(); // Error to find name foo \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedFunctionDeclarationStrictES6.ts b/tests/cases/compiler/blockScopedFunctionDeclarationStrictES6.ts new file mode 100644 index 00000000000..043890add06 --- /dev/null +++ b/tests/cases/compiler/blockScopedFunctionDeclarationStrictES6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +"use strict"; +if (true) { + function foo() { } // Allowed to declare block scope function + foo(); // This call should be ok +} +foo(); // Cannot find name since foo is block scoped \ No newline at end of file