mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
75 lines
2.9 KiB
Plaintext
75 lines
2.9 KiB
Plaintext
derivedClassWithoutExplicitConstructor3.ts(21,9): error TS2554: Expected 2 arguments, but got 0.
|
|
derivedClassWithoutExplicitConstructor3.ts(22,10): error TS2554: Expected 2 arguments, but got 1.
|
|
derivedClassWithoutExplicitConstructor3.ts(31,5): error TS2322: Type 'null' is not assignable to type 'T'.
|
|
'T' could be instantiated with an arbitrary type which could be unrelated to 'null'.
|
|
derivedClassWithoutExplicitConstructor3.ts(41,5): error TS2322: Type 'null' is not assignable to type 'T'.
|
|
'T' could be instantiated with an arbitrary type which could be unrelated to 'null'.
|
|
derivedClassWithoutExplicitConstructor3.ts(44,9): error TS2554: Expected 2 arguments, but got 0.
|
|
derivedClassWithoutExplicitConstructor3.ts(45,10): error TS2554: Expected 2 arguments, but got 1.
|
|
|
|
|
|
==== derivedClassWithoutExplicitConstructor3.ts (6 errors) ====
|
|
// automatic constructors with a class hieararchy of depth > 2
|
|
|
|
class Base {
|
|
a = 1;
|
|
constructor(x: number) { this.a = x; }
|
|
}
|
|
|
|
class Derived extends Base {
|
|
b = '';
|
|
constructor(y: string, z: string) {
|
|
super(2);
|
|
this.b = y;
|
|
}
|
|
}
|
|
|
|
class Derived2 extends Derived {
|
|
x = 1
|
|
y = 'hello';
|
|
}
|
|
|
|
var r = new Derived(); // error
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2554: Expected 2 arguments, but got 0.
|
|
!!! related TS6210 derivedClassWithoutExplicitConstructor3.ts:10:17: An argument for 'y' was not provided.
|
|
var r2 = new Derived2(1); // error
|
|
~~~~~~~~~~~~~~~
|
|
!!! error TS2554: Expected 2 arguments, but got 1.
|
|
!!! related TS6210 derivedClassWithoutExplicitConstructor3.ts:10:28: An argument for 'z' was not provided.
|
|
var r3 = new Derived('', '');
|
|
|
|
class Base2<T> {
|
|
a: T;
|
|
constructor(x: T) { this.a = x; }
|
|
}
|
|
|
|
class D<T> extends Base {
|
|
b: T = null;
|
|
~
|
|
!!! error TS2322: Type 'null' is not assignable to type 'T'.
|
|
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'null'.
|
|
constructor(y: T, z: T) {
|
|
super(2);
|
|
this.b = y;
|
|
}
|
|
}
|
|
|
|
|
|
class D2<T extends Date> extends D<T> {
|
|
x = 2
|
|
y: T = null;
|
|
~
|
|
!!! error TS2322: Type 'null' is not assignable to type 'T'.
|
|
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'null'.
|
|
}
|
|
|
|
var d = new D2(); // error
|
|
~~~~~~~~
|
|
!!! error TS2554: Expected 2 arguments, but got 0.
|
|
!!! related TS6210 derivedClassWithoutExplicitConstructor3.ts:32:17: An argument for 'y' was not provided.
|
|
var d2 = new D2(new Date()); // error
|
|
~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2554: Expected 2 arguments, but got 1.
|
|
!!! related TS6210 derivedClassWithoutExplicitConstructor3.ts:32:23: An argument for 'z' was not provided.
|
|
var d3 = new D2(new Date(), new Date()); // ok |