TypeScript/tests/cases/compiler/useBeforeDeclaration_superClass.ts
Andy 7306b13f74 Don't issue a use-before-declared error for a property that exists in a superclass (#17910)
* Don't issue a use-before-declared error for a property that exists in a superclass

* Simplify isInPropertyInitializer

* Respond to PR comments
2017-08-29 09:18:09 -07:00

28 lines
438 B
TypeScript

class C {
x = 0;
}
class D extends C {
// Not an error -- this will access the parent's initialized value for `x`, not the one on the child.
old_x = this.x;
x = 1;
}
// Test that it works on chains of classes
class X {
x = 0;
}
class Y extends X {}
class Z extends Y {
old_x = this.x;
x = 1;
}
// Interface doesn't count
interface I {
x: number;
}
class J implements I {
old_x = this.x;
x = 1;
}