19 lines
819 B
Text
19 lines
819 B
Text
|
==== tests/cases/compiler/overEagerReturnTypeSpecialization.ts (1 errors) ====
|
||
|
//Note: Below simpler repro
|
||
|
|
||
|
interface I1<T> {
|
||
|
func<U>(callback: (value: T) => U): I1<U>;
|
||
|
}
|
||
|
|
||
|
declare var v1: I1<number>;
|
||
|
var r1: I1<string> = v1.func(num => num.toString()) // Correctly returns an I1<string>
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
.func(str => str.length); // should error
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
!!! Type 'I1<number>' is not assignable to type 'I1<string>':
|
||
|
!!! Type 'number' is not assignable to type 'string'.
|
||
|
|
||
|
var r2: I1<number> = v1.func(num => num.toString()) // Correctly returns an I1<string>
|
||
|
.func(str => str.length); // should be ok
|
||
|
|
||
|
|