TypeScript/tests/baselines/reference/typeParameterAssignability3.errors.txt

40 lines
1.7 KiB
Plaintext
Raw Normal View History

2014-11-05 21:26:03 +01:00
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(14,5): error TS2322: Type 'U' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(15,5): error TS2322: Type 'T' is not assignable to type 'U'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(22,9): error TS2322: Type 'U' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(23,9): error TS2322: Type 'T' is not assignable to type 'U'.
2014-07-13 01:04:16 +02:00
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts (4 errors) ====
// type parameters are not assignable to one another unless directly or indirectly constrained to one another
class Foo { foo: string; }
function foo<T extends Foo, U extends Foo>(t: T, u: U) {
var a: T;
var b: U;
t = a; // ok
a = t; // ok
b = u; // ok
u = b; // ok
t = u; // error
~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'U' is not assignable to type 'T'.
2014-07-13 01:04:16 +02:00
u = t; // error
~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'T' is not assignable to type 'U'.
2014-07-13 01:04:16 +02:00
}
class C<T extends Foo, U extends Foo> {
t: T;
u: U;
r = () => {
this.t = this.u; // error
~~~~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'U' is not assignable to type 'T'.
2014-07-13 01:04:16 +02:00
this.u = this.t; // error
~~~~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'T' is not assignable to type 'U'.
2014-07-13 01:04:16 +02:00
}
}