TypeScript/tests/cases/compiler/initializerWithThisPropertyAccess.ts
Anders Hejlsberg 16d2eb7075
Error on this.xxx access of previously declared but uninitialized property (#38030)
* Error on this.xxx access of previously declared but uninitialized property

* Add tests

* Accept new baselines
2020-04-28 12:52:14 -07:00

36 lines
496 B
TypeScript

// @strict: true
// @declaration: true
class A {
a: number;
b = this.a; // Error
c = () => this.a;
d = (new A()).a;
constructor() {
this.a = 1;
}
}
class B extends A {
x = this.a;
}
class C {
a!: number;
b = this.a;
}
// Repro from #37979
class Foo {
private bar: Bar;
readonly barProp = this.bar.prop;
constructor() {
this.bar = new Bar();
}
}
class Bar {
readonly prop = false;
}