2014-09-12 22:35:07 +02:00
tests/cases/compiler/classUpdateTests.ts(34,2): error TS2377: Constructors for derived classes must contain a 'super' call.
tests/cases/compiler/classUpdateTests.ts(43,18): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/classUpdateTests.ts(46,17): error TS2311: A class may only extend another class.
tests/cases/compiler/classUpdateTests.ts(47,18): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/classUpdateTests.ts(57,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
2014-10-28 08:28:59 +01:00
tests/cases/compiler/classUpdateTests.ts(63,7): error TS2415: Class 'L' incorrectly extends base class 'G'.
2014-09-18 02:05:45 +02:00
Property 'p1' is private in type 'L' but not in type 'G'.
2014-10-28 08:28:59 +01:00
tests/cases/compiler/classUpdateTests.ts(69,7): error TS2415: Class 'M' incorrectly extends base class 'G'.
2014-09-18 02:05:45 +02:00
Property 'p1' is private in type 'M' but not in type 'G'.
2014-09-12 22:35:07 +02:00
tests/cases/compiler/classUpdateTests.ts(70,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
2014-12-17 00:56:56 +01:00
tests/cases/compiler/classUpdateTests.ts(93,3): error TS1129: Statement expected.
tests/cases/compiler/classUpdateTests.ts(95,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(99,3): error TS1129: Statement expected.
tests/cases/compiler/classUpdateTests.ts(101,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(105,3): error TS1129: Statement expected.
2014-09-12 22:35:07 +02:00
tests/cases/compiler/classUpdateTests.ts(105,15): error TS2339: Property 'p1' does not exist on type 'Q'.
2014-12-17 00:56:56 +01:00
tests/cases/compiler/classUpdateTests.ts(111,3): error TS1129: Statement expected.
2014-09-12 22:35:07 +02:00
tests/cases/compiler/classUpdateTests.ts(111,16): error TS2339: Property 'p1' does not exist on type 'R'.
2014-07-13 01:04:16 +02:00
==== 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
~~~~~~~~~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
2014-07-13 01:04:16 +02:00
}
class G extends D {
public p1 = 0;
constructor() { super(); } // NO ERROR
}
class H {
constructor() { super(); } // ERROR - no super call allowed
~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2335: 'super' can only be referenced in a derived class.
2014-07-13 01:04:16 +02:00
}
class I extends Object {
~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2311: A class may only extend another class.
2014-07-13 01:04:16 +02:00
constructor() { super(); } // ERROR - no super call allowed
~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2335: 'super' can only be referenced in a derived class.
2014-07-13 01:04:16 +02:00
}
class J extends G {
constructor(public p1:number) {
super(); // NO ERROR
}
}
class K extends G {
constructor(public p1:number) { // ERROR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var i = 0;
~~~~~~~~~~~~
super();
~~~~~~~~~~
}
~~
2014-09-12 00:19:57 +02:00
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
2014-07-13 01:04:16 +02:00
}
class L extends G {
~
2014-10-28 08:28:59 +01:00
!!! error TS2415: Class 'L' incorrectly extends base class 'G'.
!!! error TS2415: Property 'p1' is private in type 'L' but not in type 'G'.
2014-07-13 01:04:16 +02:00
constructor(private p1:number) {
super(); // NO ERROR
}
}
class M extends G {
~
2014-10-28 08:28:59 +01:00
!!! error TS2415: Class 'M' incorrectly extends base class 'G'.
!!! error TS2415: Property 'p1' is private in type 'M' but not in type 'G'.
2014-07-13 01:04:16 +02:00
constructor(private p1:number) { // ERROR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var i = 0;
~~~~~~~~~~~~
super();
~~~~~~~~~~
}
~~
2014-09-12 00:19:57 +02:00
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
2014-07-13 01:04:16 +02:00
}
//
// 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
~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS1129: Statement expected.
2014-07-13 01:04:16 +02:00
}
}
~
2014-09-12 00:19:57 +02:00
!!! error TS1128: Declaration or statement expected.
2014-07-13 01:04:16 +02:00
class P {
constructor() {
private p1 = 0; // ERROR
~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS1129: Statement expected.
2014-07-13 01:04:16 +02:00
}
}
~
2014-09-12 00:19:57 +02:00
!!! error TS1128: Declaration or statement expected.
2014-07-13 01:04:16 +02:00
class Q {
constructor() {
public this.p1 = 0; // ERROR
~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS1129: Statement expected.
2014-07-13 01:04:16 +02:00
~~
2014-09-12 00:19:57 +02:00
!!! error TS2339: Property 'p1' does not exist on type 'Q'.
2014-07-13 01:04:16 +02:00
}
}
class R {
constructor() {
private this.p1 = 0; // ERROR
~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS1129: Statement expected.
2014-07-13 01:04:16 +02:00
~~
2014-09-12 00:19:57 +02:00
!!! error TS2339: Property 'p1' does not exist on type 'R'.
2014-07-13 01:04:16 +02:00
}
}