Skip to content

Commit

Permalink
Test:props of class A are usable in prop initialisers of class B
Browse files Browse the repository at this point in the history
Regardless of order of class A and class B
  • Loading branch information
sandersn committed Mar 31, 2017
1 parent 87565da commit f65819a
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/baselines/reference/scopeCheckClassProperty.js
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;
}());
23 changes: 23 additions & 0 deletions tests/baselines/reference/scopeCheckClassProperty.symbols
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))
}

26 changes: 26 additions & 0 deletions tests/baselines/reference/scopeCheckClassProperty.types
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
>'' : ""
}

9 changes: 9 additions & 0 deletions tests/cases/compiler/scopeCheckClassProperty.ts
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 = '';
}

0 comments on commit f65819a

Please sign in to comment.