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

18 lines
698 B
Plaintext

==== 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>
~~
!!! Type 'I1<number>' is not assignable to type 'I1<string>':
!!! Type 'number' is not assignable to type 'string'.
.func(str => str.length); // should error
var r2: I1<number> = v1.func(num => num.toString()) // Correctly returns an I1<string>
.func(str => str.length); // should be ok