93 lines
No EOL
3.4 KiB
Text
93 lines
No EOL
3.4 KiB
Text
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/typeParameterUsedAsTypeParameterConstraint2.ts (18 errors) ====
|
|
// Type parameters are in scope in their own and other type parameter lists
|
|
// Nested local functions
|
|
|
|
function foo<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>() {
|
|
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) {
|
|
~~~~~~~~~~~
|
|
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
|
|
function bar<V extends T, W extends U>() {
|
|
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 f = function <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>() {
|
|
var g = function <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 f2 = function <U extends T, 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>() {
|
|
var g = 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>() {
|
|
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: 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>() {
|
|
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'.
|
|
}
|
|
}
|
|
} |