mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
56 lines
2.6 KiB
Plaintext
56 lines
2.6 KiB
Plaintext
derivedClassConstructorWithoutSuperCall.ts(4,5): error TS2564: Property 'x' has no initializer and is not definitely assigned in the constructor.
|
|
derivedClassConstructorWithoutSuperCall.ts(8,5): error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
derivedClassConstructorWithoutSuperCall.ts(13,5): error TS2564: Property 'x' has no initializer and is not definitely assigned in the constructor.
|
|
derivedClassConstructorWithoutSuperCall.ts(17,5): error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
|
derivedClassConstructorWithoutSuperCall.ts(23,5): error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
|
|
|
|
|
==== derivedClassConstructorWithoutSuperCall.ts (7 errors) ====
|
|
// derived class constructors must contain a super call
|
|
|
|
class Base {
|
|
x: string;
|
|
~
|
|
!!! error TS2564: Property 'x' has no initializer and is not definitely assigned in the constructor.
|
|
}
|
|
|
|
class Derived extends Base {
|
|
constructor() { // error
|
|
~~~~~~~~~~~
|
|
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
}
|
|
}
|
|
|
|
class Base2<T> {
|
|
x: T;
|
|
~
|
|
!!! error TS2564: Property 'x' has no initializer and is not definitely assigned in the constructor.
|
|
}
|
|
|
|
class Derived2<T> extends Base2<T> {
|
|
constructor() { // error for no super call (nested scopes don't count)
|
|
~~~~~~~~~~~
|
|
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
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.
|
|
}
|
|
}
|
|
|
|
class Derived3<T> extends Base2<T> {
|
|
constructor() { // error
|
|
~~~~~~~~~~~
|
|
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
|
|
var r = function () { super() } // error
|
|
~~~~~
|
|
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
|
}
|
|
}
|
|
|
|
class Derived4<T> extends Base2<T> {
|
|
constructor() {
|
|
var r = super(); // ok
|
|
}
|
|
} |