Skip to content

Commit f65819a

Browse files
committed
Test:props of class A are usable in prop initialisers of class B
Regardless of order of class A and class B
1 parent 87565da commit f65819a

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//// [scopeCheckClassProperty.ts]
2+
class C {
3+
constructor() {
4+
new A().p; // ok
5+
}
6+
public x = new A().p; // should also be ok
7+
}
8+
class A {
9+
public p = '';
10+
}
11+
12+
13+
//// [scopeCheckClassProperty.js]
14+
var C = (function () {
15+
function C() {
16+
this.x = new A().p; // should also be ok
17+
new A().p; // ok
18+
}
19+
return C;
20+
}());
21+
var A = (function () {
22+
function A() {
23+
this.p = '';
24+
}
25+
return A;
26+
}());
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/compiler/scopeCheckClassProperty.ts ===
2+
class C {
3+
>C : Symbol(C, Decl(scopeCheckClassProperty.ts, 0, 0))
4+
5+
constructor() {
6+
new A().p; // ok
7+
>new A().p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9))
8+
>A : Symbol(A, Decl(scopeCheckClassProperty.ts, 5, 1))
9+
>p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9))
10+
}
11+
public x = new A().p; // should also be ok
12+
>x : Symbol(C.x, Decl(scopeCheckClassProperty.ts, 3, 3))
13+
>new A().p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9))
14+
>A : Symbol(A, Decl(scopeCheckClassProperty.ts, 5, 1))
15+
>p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9))
16+
}
17+
class A {
18+
>A : Symbol(A, Decl(scopeCheckClassProperty.ts, 5, 1))
19+
20+
public p = '';
21+
>p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9))
22+
}
23+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=== tests/cases/compiler/scopeCheckClassProperty.ts ===
2+
class C {
3+
>C : C
4+
5+
constructor() {
6+
new A().p; // ok
7+
>new A().p : string
8+
>new A() : A
9+
>A : typeof A
10+
>p : string
11+
}
12+
public x = new A().p; // should also be ok
13+
>x : string
14+
>new A().p : string
15+
>new A() : A
16+
>A : typeof A
17+
>p : string
18+
}
19+
class A {
20+
>A : A
21+
22+
public p = '';
23+
>p : string
24+
>'' : ""
25+
}
26+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class C {
2+
constructor() {
3+
new A().p; // ok
4+
}
5+
public x = new A().p; // should also be ok
6+
}
7+
class A {
8+
public p = '';
9+
}

0 commit comments

Comments
 (0)