TypeScript/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt
2014-07-12 17:30:19 -07:00

126 lines
4.1 KiB
Plaintext

==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (18 errors) ====
// checking whether other types are subtypes of type parameters with constraints
class Foo { foo: number; }
function f<T extends Foo, U extends Foo, V>(t: T, u: U, v: V) {
// error
var r = true ? t : u;
~~~~~~~~~~~~
!!! No best common type exists between 'T' and 'U'.
var r = true ? u : t;
~~~~~~~~~~~~
!!! No best common type exists between 'U' and 'T'.
// error
var r2 = true ? t : v;
~~~~~~~~~~~~
!!! No best common type exists between 'T' and 'V'.
var r2 = true ? v : t;
~~~~~~~~~~~~
!!! No best common type exists between 'V' and 'T'.
// error
var r3 = true ? v : u;
~~~~~~~~~~~~
!!! No best common type exists between 'V' and 'U'.
var r3 = true ? u : v;
~~~~~~~~~~~~
!!! No best common type exists between 'U' and 'V'.
// ok
var r4 = true ? t : new Foo();
var r4 = true ? new Foo() : t;
// ok
var r5 = true ? u : new Foo();
var r5 = true ? new Foo() : u;
// BUG, should be error
var r6 = true ? v : new Foo();
~~~~~~~~~~~~~~~~~~~~
!!! No best common type exists between 'V' and 'Foo'.
var r6 = true ? new Foo() : v;
~~~~~~~~~~~~~~~~~~~~
!!! No best common type exists between 'Foo' and 'V'.
}
class B1<T> {
foo: T;
}
class D1<T extends Foo, U extends Foo, V> extends B1<Foo> {
[x: string]: Foo;
foo: T; // ok
}
class D2<T extends Foo, U extends Foo, V> extends B1<Foo> {
[x: string]: Foo;
foo: U; // ok
}
class D3<T extends Foo, U extends Foo, V> extends B1<Foo> {
~~
!!! Class 'D3<T, U, V>' incorrectly extends base class 'B1<Foo>':
!!! Types of property 'foo' are incompatible:
!!! Type 'V' is not assignable to type 'Foo':
!!! Property 'foo' is missing in type '{}'.
[x: string]: Foo;
foo: V; // error
~~~~~~~
!!! Property 'foo' of type 'V' is not assignable to string index type 'Foo'.
}
class D4<T extends Foo, U extends Foo, V> extends B1<T> {
[x: string]: T;
foo: T; // ok
}
class D5<T extends Foo, U extends Foo, V> extends B1<T> {
~~
!!! Class 'D5<T, U, V>' incorrectly extends base class 'B1<T>':
!!! Types of property 'foo' are incompatible:
!!! Type 'U' is not assignable to type 'T'.
[x: string]: T;
foo: U; // error
~~~~~~~
!!! Property 'foo' of type 'U' is not assignable to string index type 'T'.
}
class D6<T extends Foo, U extends Foo, V> extends B1<T> {
~~
!!! Class 'D6<T, U, V>' incorrectly extends base class 'B1<T>':
!!! Types of property 'foo' are incompatible:
!!! Type 'V' is not assignable to type 'T'.
[x: string]: T;
foo: V; // error
~~~~~~~
!!! Property 'foo' of type 'V' is not assignable to string index type 'T'.
}
class D7<T extends Foo, U extends Foo, V> extends B1<U> {
~~
!!! Class 'D7<T, U, V>' incorrectly extends base class 'B1<U>':
!!! Types of property 'foo' are incompatible:
!!! Type 'T' is not assignable to type 'U'.
[x: string]: U;
foo: T; // error
~~~~~~~
!!! Property 'foo' of type 'T' is not assignable to string index type 'U'.
}
class D8<T extends Foo, U extends Foo, V> extends B1<U> {
[x: string]: U;
foo: U; // ok
}
class D9<T extends Foo, U extends Foo, V> extends B1<U> {
~~
!!! Class 'D9<T, U, V>' incorrectly extends base class 'B1<U>':
!!! Types of property 'foo' are incompatible:
!!! Type 'V' is not assignable to type 'U'.
[x: string]: U;
foo: V; // error
~~~~~~~
!!! Property 'foo' of type 'V' is not assignable to string index type 'U'.
}