-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test:props of class A are usable in prop initialisers of class B
Regardless of order of class A and class B
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//// [scopeCheckClassProperty.ts] | ||
class C { | ||
constructor() { | ||
new A().p; // ok | ||
} | ||
public x = new A().p; // should also be ok | ||
} | ||
class A { | ||
public p = ''; | ||
} | ||
|
||
|
||
//// [scopeCheckClassProperty.js] | ||
var C = (function () { | ||
function C() { | ||
this.x = new A().p; // should also be ok | ||
new A().p; // ok | ||
} | ||
return C; | ||
}()); | ||
var A = (function () { | ||
function A() { | ||
this.p = ''; | ||
} | ||
return A; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
=== tests/cases/compiler/scopeCheckClassProperty.ts === | ||
class C { | ||
>C : Symbol(C, Decl(scopeCheckClassProperty.ts, 0, 0)) | ||
|
||
constructor() { | ||
new A().p; // ok | ||
>new A().p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9)) | ||
>A : Symbol(A, Decl(scopeCheckClassProperty.ts, 5, 1)) | ||
>p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9)) | ||
} | ||
public x = new A().p; // should also be ok | ||
>x : Symbol(C.x, Decl(scopeCheckClassProperty.ts, 3, 3)) | ||
>new A().p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9)) | ||
>A : Symbol(A, Decl(scopeCheckClassProperty.ts, 5, 1)) | ||
>p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9)) | ||
} | ||
class A { | ||
>A : Symbol(A, Decl(scopeCheckClassProperty.ts, 5, 1)) | ||
|
||
public p = ''; | ||
>p : Symbol(A.p, Decl(scopeCheckClassProperty.ts, 6, 9)) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
=== tests/cases/compiler/scopeCheckClassProperty.ts === | ||
class C { | ||
>C : C | ||
|
||
constructor() { | ||
new A().p; // ok | ||
>new A().p : string | ||
>new A() : A | ||
>A : typeof A | ||
>p : string | ||
} | ||
public x = new A().p; // should also be ok | ||
>x : string | ||
>new A().p : string | ||
>new A() : A | ||
>A : typeof A | ||
>p : string | ||
} | ||
class A { | ||
>A : A | ||
|
||
public p = ''; | ||
>p : string | ||
>'' : "" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class C { | ||
constructor() { | ||
new A().p; // ok | ||
} | ||
public x = new A().p; // should also be ok | ||
} | ||
class A { | ||
public p = ''; | ||
} |