55 lines
No EOL
2.7 KiB
Text
55 lines
No EOL
2.7 KiB
Text
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(8,5): error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(17,5): error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
|
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(23,5): error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
|
|
|
|
|
==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts (5 errors) ====
|
|
// derived class constructors must contain a super call
|
|
|
|
class Base {
|
|
x: string;
|
|
}
|
|
|
|
class Derived extends Base {
|
|
constructor() { // error
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
}
|
|
~~~~~
|
|
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
}
|
|
|
|
class Base2<T> {
|
|
x: T;
|
|
}
|
|
|
|
class Derived2<T> extends Base2<T> {
|
|
constructor() { // error for no super call (nested scopes don't count)
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
var r2 = () => super(); // error for misplaced super call (nested function)
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
~~~~~
|
|
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
|
}
|
|
~~~~~
|
|
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
}
|
|
|
|
class Derived3<T> extends Base2<T> {
|
|
constructor() { // error
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
var r = function () { super() } // error
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
~~~~~
|
|
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
|
}
|
|
~~~~~
|
|
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
}
|
|
|
|
class Derived4<T> extends Base2<T> {
|
|
constructor() {
|
|
var r = super(); // ok
|
|
}
|
|
} |