==== tests/cases/compiler/classUpdateTests.ts (16 errors) ==== // // test codegen for instance properties // class A { public p1 = 0; private p2 = 0; p3; } class B { public p1 = 0; private p2 = 0; p3; constructor() {} } class C { constructor(public p1=0, private p2=0, p3=0) {} } // // test requirements for super calls // class D { // NO ERROR } class E extends D { // NO ERROR public p1 = 0; } class F extends E { constructor() {} // ERROR - super call required ~~~~~~~~~~~~~~~~ !!! Constructors for derived classes must contain a 'super' call. } class G extends D { public p1 = 0; constructor() { super(); } // NO ERROR } class H { constructor() { super(); } // ERROR - no super call allowed ~~~~~ !!! 'super' can only be referenced in a derived class. } class I extends Object { ~~~~~~ !!! A class may only extend another class. constructor() { super(); } // ERROR - no super call allowed ~~~~~ !!! 'super' can only be referenced in a derived class. } class J extends G { constructor(public p1:number) { super(); // NO ERROR } } class K extends G { constructor(public p1:number) { // ERROR ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var i = 0; ~~~~~~~~~~~~ super(); ~~~~~~~~~~ } ~~ !!! A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. } class L extends G { ~ !!! Class 'L' incorrectly extends base class 'G': !!! Private property 'p1' cannot be reimplemented. constructor(private p1:number) { super(); // NO ERROR } } class M extends G { ~ !!! Class 'M' incorrectly extends base class 'G': !!! Private property 'p1' cannot be reimplemented. constructor(private p1:number) { // ERROR ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var i = 0; ~~~~~~~~~~~~ super(); ~~~~~~~~~~ } ~~ !!! A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. } // // test this reference in field initializers // class N { public p1 = 0; public p2 = this.p1; constructor() { this.p2 = 0; } } // // test error on property declarations within class constructors // class O { constructor() { public p1 = 0; // ERROR ~~~~~~ !!! Statement expected. } } ~ !!! Declaration or statement expected. class P { constructor() { private p1 = 0; // ERROR ~~~~~~~ !!! Statement expected. } } ~ !!! Declaration or statement expected. class Q { constructor() { public this.p1 = 0; // ERROR ~~~~~~ !!! Statement expected. ~~ !!! Property 'p1' does not exist on type 'Q'. } } class R { constructor() { private this.p1 = 0; // ERROR ~~~~~~~ !!! Statement expected. ~~ !!! Property 'p1' does not exist on type 'R'. } }