mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-29 19:42:39 -05:00
Test:props of class A are usable in prop initialisers of class B
Regardless of order of class A and class B
This commit is contained in:
26
tests/baselines/reference/scopeCheckClassProperty.js
Normal file
26
tests/baselines/reference/scopeCheckClassProperty.js
Normal file
@@ -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;
|
||||
}());
|
||||
23
tests/baselines/reference/scopeCheckClassProperty.symbols
Normal file
23
tests/baselines/reference/scopeCheckClassProperty.symbols
Normal file
@@ -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))
|
||||
}
|
||||
|
||||
26
tests/baselines/reference/scopeCheckClassProperty.types
Normal file
26
tests/baselines/reference/scopeCheckClassProperty.types
Normal file
@@ -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
|
||||
>'' : ""
|
||||
}
|
||||
|
||||
9
tests/cases/compiler/scopeCheckClassProperty.ts
Normal file
9
tests/cases/compiler/scopeCheckClassProperty.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
constructor() {
|
||||
new A().p; // ok
|
||||
}
|
||||
public x = new A().p; // should also be ok
|
||||
}
|
||||
class A {
|
||||
public p = '';
|
||||
}
|
||||
Reference in New Issue
Block a user