mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
19 lines
778 B
Plaintext
19 lines
778 B
Plaintext
genericConstraint1.ts(3,9): error TS2322: Type 'null' is not assignable to type 'T'.
|
|
'T' could be instantiated with an arbitrary type which could be unrelated to 'null'.
|
|
genericConstraint1.ts(8,8): error TS2344: Type 'string' does not satisfy the constraint 'number'.
|
|
|
|
|
|
==== genericConstraint1.ts (2 errors) ====
|
|
class C<T> {
|
|
public bar2<U extends T>(x: T, y: U): T {
|
|
return 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 x = new C<number>();
|
|
x.bar2<string>(2, "");
|
|
~~~~~~
|
|
!!! error TS2344: Type 'string' does not satisfy the constraint 'number'. |