TypeScript/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint.errors.txt
2014-09-11 16:11:08 -07:00

68 lines
2.6 KiB
Plaintext

==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint.ts (18 errors) ====
// Type parameters are in scope in their own and other type parameter lists
function foo<T, U extends T>(x: T, y: U): T {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
x = y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
return y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
}
function foo2<U extends T, T>(x: T, y: U): T {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
x = y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
return y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
}
var f = function <T, U extends T>(x: T, y: U): T {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
x = y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
return y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
}
var f2 = function <U extends T, T>(x: T, y: U): T {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
x = y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
return y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
}
var f3 = <T, U extends T>(x: T, y: U): T => {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
x = y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
return y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
}
var f4 = <U extends T, T>(x: T, y: U): T => {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
x = y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
return y;
~
!!! error TS2323: Type 'U' is not assignable to type 'T'.
}