Skip to content

Commit 3831804

Browse files
committed
Test:reference ambient block scoped vars in different file
1 parent 7dd3cde commit 3831804

File tree

4 files changed

+147
-0
lines changed

4 files changed

+147
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//// [tests/cases/compiler/blockScopedNamespaceDifferentFile.ts] ////
2+
3+
//// [test.ts]
4+
// #15734 failed when test.ts comes before typings.d.ts
5+
namespace C {
6+
export class Name {
7+
static funcData = A.AA.func();
8+
static someConst = A.AA.foo;
9+
10+
constructor(parameters) {}
11+
}
12+
}
13+
14+
//// [typings.d.ts]
15+
declare namespace A {
16+
namespace AA {
17+
function func(): number;
18+
const foo = "";
19+
}
20+
}
21+
22+
23+
//// [out.js]
24+
// #15734 failed when test.ts comes before typings.d.ts
25+
var C;
26+
(function (C) {
27+
var Name = (function () {
28+
function Name(parameters) {
29+
}
30+
return Name;
31+
}());
32+
Name.funcData = A.AA.func();
33+
Name.someConst = A.AA.foo;
34+
C.Name = Name;
35+
})(C || (C = {}));
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
=== tests/cases/compiler/test.ts ===
2+
// #15734 failed when test.ts comes before typings.d.ts
3+
namespace C {
4+
>C : Symbol(C, Decl(test.ts, 0, 0))
5+
6+
export class Name {
7+
>Name : Symbol(Name, Decl(test.ts, 1, 13))
8+
9+
static funcData = A.AA.func();
10+
>funcData : Symbol(Name.funcData, Decl(test.ts, 2, 23))
11+
>A.AA.func : Symbol(A.AA.func, Decl(typings.d.ts, 1, 18))
12+
>A.AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21))
13+
>A : Symbol(A, Decl(typings.d.ts, 0, 0))
14+
>AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21))
15+
>func : Symbol(A.AA.func, Decl(typings.d.ts, 1, 18))
16+
17+
static someConst = A.AA.foo;
18+
>someConst : Symbol(Name.someConst, Decl(test.ts, 3, 38))
19+
>A.AA.foo : Symbol(A.AA.foo, Decl(typings.d.ts, 3, 13))
20+
>A.AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21))
21+
>A : Symbol(A, Decl(typings.d.ts, 0, 0))
22+
>AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21))
23+
>foo : Symbol(A.AA.foo, Decl(typings.d.ts, 3, 13))
24+
25+
constructor(parameters) {}
26+
>parameters : Symbol(parameters, Decl(test.ts, 6, 20))
27+
}
28+
}
29+
30+
=== tests/cases/compiler/typings.d.ts ===
31+
declare namespace A {
32+
>A : Symbol(A, Decl(typings.d.ts, 0, 0))
33+
34+
namespace AA {
35+
>AA : Symbol(AA, Decl(typings.d.ts, 0, 21))
36+
37+
function func(): number;
38+
>func : Symbol(func, Decl(typings.d.ts, 1, 18))
39+
40+
const foo = "";
41+
>foo : Symbol(foo, Decl(typings.d.ts, 3, 13))
42+
}
43+
}
44+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
=== tests/cases/compiler/test.ts ===
2+
// #15734 failed when test.ts comes before typings.d.ts
3+
namespace C {
4+
>C : typeof C
5+
6+
export class Name {
7+
>Name : Name
8+
9+
static funcData = A.AA.func();
10+
>funcData : number
11+
>A.AA.func() : number
12+
>A.AA.func : () => number
13+
>A.AA : typeof A.AA
14+
>A : typeof A
15+
>AA : typeof A.AA
16+
>func : () => number
17+
18+
static someConst = A.AA.foo;
19+
>someConst : string
20+
>A.AA.foo : ""
21+
>A.AA : typeof A.AA
22+
>A : typeof A
23+
>AA : typeof A.AA
24+
>foo : ""
25+
26+
constructor(parameters) {}
27+
>parameters : any
28+
}
29+
}
30+
31+
=== tests/cases/compiler/typings.d.ts ===
32+
declare namespace A {
33+
>A : typeof A
34+
35+
namespace AA {
36+
>AA : typeof AA
37+
38+
function func(): number;
39+
>func : () => number
40+
41+
const foo = "";
42+
>foo : ""
43+
>"" : ""
44+
}
45+
}
46+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @target: es5
2+
// @outFile: out.js
3+
// @module: amd
4+
5+
// #15734 failed when test.ts comes before typings.d.ts
6+
// @Filename: test.ts
7+
namespace C {
8+
export class Name {
9+
static funcData = A.AA.func();
10+
static someConst = A.AA.foo;
11+
12+
constructor(parameters) {}
13+
}
14+
}
15+
16+
// @Filename: typings.d.ts
17+
declare namespace A {
18+
namespace AA {
19+
function func(): number;
20+
const foo = "";
21+
}
22+
}

0 commit comments

Comments
 (0)