Skip to content

Commit 42ac23a

Browse files
committed
Test: typeof can refer to block-scoped var before declaration
1 parent 03b12e8 commit 42ac23a

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//// [typeofUsedBeforeBlockScoped.ts]
2+
// TODO: Change name of file to typeofUsedBeforeBlockScoped.ts
3+
type T = typeof C & typeof C.s & typeof o & typeof o.n;
4+
class C {
5+
static s = 2;
6+
}
7+
type W = typeof o.n;
8+
let o2: typeof o;
9+
let o = { n: 12 };
10+
11+
12+
//// [typeofUsedBeforeBlockScoped.js]
13+
var C = (function () {
14+
function C() {
15+
}
16+
return C;
17+
}());
18+
C.s = 2;
19+
var o2;
20+
var o = { n: 12 };
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=== tests/cases/compiler/typeofUsedBeforeBlockScoped.ts ===
2+
// TODO: Change name of file to typeofUsedBeforeBlockScoped.ts
3+
type T = typeof C & typeof C.s & typeof o & typeof o.n;
4+
>T : Symbol(T, Decl(typeofUsedBeforeBlockScoped.ts, 0, 0))
5+
>C : Symbol(C, Decl(typeofUsedBeforeBlockScoped.ts, 1, 55))
6+
>C.s : Symbol(C.s, Decl(typeofUsedBeforeBlockScoped.ts, 2, 9))
7+
>C : Symbol(C, Decl(typeofUsedBeforeBlockScoped.ts, 1, 55))
8+
>s : Symbol(C.s, Decl(typeofUsedBeforeBlockScoped.ts, 2, 9))
9+
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 7, 3))
10+
>o.n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 7, 9))
11+
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 7, 3))
12+
>n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 7, 9))
13+
14+
class C {
15+
>C : Symbol(C, Decl(typeofUsedBeforeBlockScoped.ts, 1, 55))
16+
17+
static s = 2;
18+
>s : Symbol(C.s, Decl(typeofUsedBeforeBlockScoped.ts, 2, 9))
19+
}
20+
type W = typeof o.n;
21+
>W : Symbol(W, Decl(typeofUsedBeforeBlockScoped.ts, 4, 1))
22+
>o.n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 7, 9))
23+
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 7, 3))
24+
>n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 7, 9))
25+
26+
let o2: typeof o;
27+
>o2 : Symbol(o2, Decl(typeofUsedBeforeBlockScoped.ts, 6, 3))
28+
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 7, 3))
29+
30+
let o = { n: 12 };
31+
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 7, 3))
32+
>n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 7, 9))
33+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=== tests/cases/compiler/typeofUsedBeforeBlockScoped.ts ===
2+
// TODO: Change name of file to typeofUsedBeforeBlockScoped.ts
3+
type T = typeof C & typeof C.s & typeof o & typeof o.n;
4+
>T : T
5+
>C : typeof C
6+
>C.s : number
7+
>C : typeof C
8+
>s : number
9+
>o : { n: number; }
10+
>o.n : number
11+
>o : { n: number; }
12+
>n : number
13+
14+
class C {
15+
>C : C
16+
17+
static s = 2;
18+
>s : number
19+
>2 : 2
20+
}
21+
type W = typeof o.n;
22+
>W : number
23+
>o.n : number
24+
>o : { n: number; }
25+
>n : number
26+
27+
let o2: typeof o;
28+
>o2 : { n: number; }
29+
>o : { n: number; }
30+
31+
let o = { n: 12 };
32+
>o : { n: number; }
33+
>{ n: 12 } : { n: number; }
34+
>n : number
35+
>12 : 12
36+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// TODO: Change name of file to typeofUsedBeforeBlockScoped.ts
2+
type T = typeof C & typeof C.s & typeof o & typeof o.n;
3+
class C {
4+
static s = 2;
5+
}
6+
type W = typeof o.n;
7+
let o2: typeof o;
8+
let o = { n: 12 };

0 commit comments

Comments
 (0)