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

18 lines
698 B
Plaintext
Raw Normal View History

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