Test cases for let declaration and its use order
This commit is contained in:
parent
5aa7086b81
commit
1ae1464764
7 changed files with 106 additions and 0 deletions
|
@ -0,0 +1,21 @@
|
|||
//// [tests/cases/compiler/jsFileCompilationLetDeclarationOrder.ts] ////
|
||||
|
||||
//// [b.js]
|
||||
let a = 10;
|
||||
b = 30;
|
||||
|
||||
//// [a.ts]
|
||||
let b = 30;
|
||||
a = 10;
|
||||
|
||||
|
||||
//// [out.js]
|
||||
var a = 10;
|
||||
b = 30;
|
||||
var b = 30;
|
||||
a = 10;
|
||||
|
||||
|
||||
//// [out.d.ts]
|
||||
declare let a: number;
|
||||
declare let b: number;
|
|
@ -0,0 +1,14 @@
|
|||
=== tests/cases/compiler/b.js ===
|
||||
let a = 10;
|
||||
>a : Symbol(a, Decl(b.js, 0, 3))
|
||||
|
||||
b = 30;
|
||||
>b : Symbol(b, Decl(a.ts, 0, 3))
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
let b = 30;
|
||||
>b : Symbol(b, Decl(a.ts, 0, 3))
|
||||
|
||||
a = 10;
|
||||
>a : Symbol(a, Decl(b.js, 0, 3))
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
=== tests/cases/compiler/b.js ===
|
||||
let a = 10;
|
||||
>a : number
|
||||
>10 : number
|
||||
|
||||
b = 30;
|
||||
>b = 30 : number
|
||||
>b : number
|
||||
>30 : number
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
let b = 30;
|
||||
>b : number
|
||||
>30 : number
|
||||
|
||||
a = 10;
|
||||
>a = 10 : number
|
||||
>a : number
|
||||
>10 : number
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
tests/cases/compiler/a.ts(2,1): error TS2448: Block-scoped variable 'a' used before its declaration.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.ts (1 errors) ====
|
||||
let b = 30;
|
||||
a = 10;
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'a' used before its declaration.
|
||||
==== tests/cases/compiler/b.js (0 errors) ====
|
||||
let a = 10;
|
||||
b = 30;
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
//// [tests/cases/compiler/jsFileCompilationLetDeclarationOrder2.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
let b = 30;
|
||||
a = 10;
|
||||
//// [b.js]
|
||||
let a = 10;
|
||||
b = 30;
|
||||
|
||||
|
||||
//// [out.js]
|
||||
var b = 30;
|
||||
a = 10;
|
||||
var a = 10;
|
||||
b = 30;
|
||||
|
||||
|
||||
//// [out.d.ts]
|
||||
declare let b: number;
|
||||
declare let a: number;
|
10
tests/cases/compiler/jsFileCompilationLetDeclarationOrder.ts
Normal file
10
tests/cases/compiler/jsFileCompilationLetDeclarationOrder.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: b.js
|
||||
let a = 10;
|
||||
b = 30;
|
||||
|
||||
// @filename: a.ts
|
||||
let b = 30;
|
||||
a = 10;
|
|
@ -0,0 +1,9 @@
|
|||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
let b = 30;
|
||||
a = 10;
|
||||
// @filename: b.js
|
||||
let a = 10;
|
||||
b = 30;
|
Loading…
Reference in a new issue