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

112 lines
4.6 KiB
Plaintext

==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint4.ts (29 errors) ====
// Type parameters are in scope in their own and other type parameter lists
// Some negative cases
class C<T, U extends T, V extends U> {
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
z: W; // error
~
!!! Cannot find name 'W'.
foo<W extends V>(x: W): T {
var r: T;
return x;
~
!!! Type 'W' is not assignable to type 'T'.
}
}
interface I<T, U extends T, V extends U> {
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
x: T;
y: U;
z: W; // error
~
!!! Cannot find name 'W'.
foo<W extends V>(x: W): T;
}
function foo<T, U extends T>(x: T, y: U): V { // error
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
~
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
~
!!! Cannot find name 'V'.
function bar<V extends T, W extends U>(): X { // error
~
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
~
!!! Cannot find name 'X'.
function baz<X extends W, Y extends V>(a: X, b: Y): T {
x = y;
~
!!! Type 'U' is not assignable to type 'T'.
return y;
~
!!! Type 'U' is not assignable to type 'T'.
}
}
}
function foo2<U extends T, T>(x: T, y: U): W { // error
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
~
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
~
!!! Cannot find name 'W'.
function bar<V extends T, W extends U>(): Y { // error
~
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
~
!!! Cannot find name 'Y'.
function baz<X extends W, Y extends V>(a: X, b: Y): T {
x = y;
~
!!! Type 'U' is not assignable to type 'T'.
return y;
~
!!! Type 'U' is not assignable to type 'T'.
}
}
}
var f3 = <T, U extends T>(x: T, y: U) => {
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
function bar<V extends T, W extends U>(r: X, s: Y) { // error
~
!!! Cannot find name 'X'.
~
!!! Cannot find name 'Y'.
var g = <X extends W, Y extends V>(a: X, b: Y): T => {
x = y;
~
!!! Type 'U' is not assignable to type 'T'.
return y;
~
!!! Type 'U' is not assignable to type 'T'.
}
}
}
var f4 = <U extends T, T>(x: V, y: X) => { // error
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
~
!!! Cannot find name 'V'.
~
!!! Cannot find name 'X'.
function bar<V extends T, W extends U>() {
var g = <X extends W, Y extends V>(a: X, b: Y): T => {
x = y;
return y;
}
}
}