mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
41 lines
1.5 KiB
Plaintext
41 lines
1.5 KiB
Plaintext
derivedClassWithoutExplicitConstructor.ts(11,9): error TS2554: Expected 1 arguments, but got 0.
|
|
derivedClassWithoutExplicitConstructor.ts(21,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'.
|
|
derivedClassWithoutExplicitConstructor.ts(24,9): error TS2554: Expected 1 arguments, but got 0.
|
|
|
|
|
|
==== derivedClassWithoutExplicitConstructor.ts (3 errors) ====
|
|
class Base {
|
|
a = 1;
|
|
constructor(x: number) { this.a = x; }
|
|
}
|
|
|
|
class Derived extends Base {
|
|
x = 1
|
|
y = 'hello';
|
|
}
|
|
|
|
var r = new Derived(); // error
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2554: Expected 1 arguments, but got 0.
|
|
!!! related TS6210 derivedClassWithoutExplicitConstructor.ts:3:17: An argument for 'x' was not provided.
|
|
var r2 = new Derived(1);
|
|
|
|
class Base2<T> {
|
|
a: T;
|
|
constructor(x: T) { this.a = x; }
|
|
}
|
|
|
|
class D<T extends Date> extends Base2<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 D(); // error
|
|
~~~~~~~
|
|
!!! error TS2554: Expected 1 arguments, but got 0.
|
|
!!! related TS6210 derivedClassWithoutExplicitConstructor.ts:16:17: An argument for 'x' was not provided.
|
|
var d2 = new D(new Date()); // ok |