2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/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>() };
|
2014-07-19 02:30:06 +02:00
|
|
|
~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type '{ x: A<number>; }' is not assignable to type 'I<string>':
|
|
|
|
!!! Types of property 'x' are incompatible:
|
|
|
|
!!! 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 'number' is not assignable to type 'string'.
|
|
|
|
var a2: I<string> = function (): { x: A<number> } {
|
2014-07-19 02:30:06 +02:00
|
|
|
~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type '{ x: A<number>; }' is not assignable to type 'I<string>':
|
|
|
|
!!! Types of property 'x' are incompatible:
|
|
|
|
!!! 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 'number' is not assignable to type 'string'.
|
2014-07-19 02:30:06 +02:00
|
|
|
var z = { x: new A<number>() }; return z;
|
|
|
|
} ();
|
2014-07-13 01:04:16 +02:00
|
|
|
var a3: I<string> = z;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type '{ x: A<number>; }' is not assignable to type 'I<string>':
|
|
|
|
!!! Types of property 'x' are incompatible:
|
|
|
|
!!! 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 'number' is not assignable to type 'string'.
|
|
|
|
var a4: I<string> = <K<number>>z;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'K<number>' is not assignable to type 'I<string>':
|
|
|
|
!!! Types of property 'x' are incompatible:
|
|
|
|
!!! 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 'number' is not assignable to type 'string'.
|
|
|
|
|
|
|
|
|