mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
67 lines
4.1 KiB
Plaintext
67 lines
4.1 KiB
Plaintext
genericAssignmentCompatWithInterfaces1.ts(12,23): error TS2322: Type 'A<number>' is not assignable to type 'Comparable<string>'.
|
|
Types of property 'compareTo' are incompatible.
|
|
Type '(other: number) => number' is not assignable to type '(other: string) => number'.
|
|
Types of parameters 'other' and 'other' are incompatible.
|
|
Type 'string' is not assignable to type 'number'.
|
|
genericAssignmentCompatWithInterfaces1.ts(13,5): error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
|
|
The types of 'x.compareTo' are incompatible between these types.
|
|
Type '(other: number) => number' is not assignable to type '(other: string) => number'.
|
|
Types of parameters 'other' and 'other' are incompatible.
|
|
Type 'string' is not assignable to type 'number'.
|
|
genericAssignmentCompatWithInterfaces1.ts(16,5): error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
|
|
The types of 'x.compareTo' are incompatible between these types.
|
|
Type '(other: number) => number' is not assignable to type '(other: string) => number'.
|
|
Types of parameters 'other' and 'other' are incompatible.
|
|
Type 'string' is not assignable to type 'number'.
|
|
genericAssignmentCompatWithInterfaces1.ts(17,5): error TS2322: Type 'K<number>' is not assignable to type 'I<string>'.
|
|
The types of 'x.compareTo' are incompatible between these types.
|
|
Type '(other: number) => number' is not assignable to type '(other: string) => number'.
|
|
Types of parameters 'other' and 'other' are incompatible.
|
|
Type 'string' is not assignable to type 'number'.
|
|
|
|
|
|
==== genericAssignmentCompatWithInterfaces1.ts (4 errors) ====
|
|
interface Comparable<T> {
|
|
compareTo(other: T): number;
|
|
}
|
|
interface I<T> {
|
|
x: Comparable<T>;
|
|
}
|
|
interface K<T> {
|
|
x: A<T>;
|
|
}
|
|
class A<T> implements Comparable<T> { compareTo(other: T) { return 1; } }
|
|
var z = { x: new A<number>() };
|
|
var a1: I<string> = { x: new A<number>() };
|
|
~
|
|
!!! error TS2322: Type 'A<number>' is not assignable to type 'Comparable<string>'.
|
|
!!! error TS2322: Types of property 'compareTo' are incompatible.
|
|
!!! error TS2322: Type '(other: number) => number' is not assignable to type '(other: string) => number'.
|
|
!!! error TS2322: Types of parameters 'other' and 'other' are incompatible.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
!!! related TS6500 genericAssignmentCompatWithInterfaces1.ts:5:5: The expected type comes from property 'x' which is declared here on type 'I<string>'
|
|
var a2: I<string> = function (): { x: A<number> } {
|
|
~~
|
|
!!! error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
|
|
!!! error TS2322: The types of 'x.compareTo' are incompatible between these types.
|
|
!!! error TS2322: Type '(other: number) => number' is not assignable to type '(other: string) => number'.
|
|
!!! error TS2322: Types of parameters 'other' and 'other' are incompatible.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
var z = { x: new A<number>() }; return z;
|
|
} ();
|
|
var a3: I<string> = z;
|
|
~~
|
|
!!! error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
|
|
!!! error TS2322: The types of 'x.compareTo' are incompatible between these types.
|
|
!!! error TS2322: Type '(other: number) => number' is not assignable to type '(other: string) => number'.
|
|
!!! error TS2322: Types of parameters 'other' and 'other' are incompatible.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
var a4: I<string> = <K<number>>z;
|
|
~~
|
|
!!! error TS2322: Type 'K<number>' is not assignable to type 'I<string>'.
|
|
!!! error TS2322: The types of 'x.compareTo' are incompatible between these types.
|
|
!!! error TS2322: Type '(other: number) => number' is not assignable to type '(other: string) => number'.
|
|
!!! error TS2322: Types of parameters 'other' and 'other' are incompatible.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
|
|
|