22 lines
920 B
Plaintext
22 lines
920 B
Plaintext
tests/cases/compiler/overEagerReturnTypeSpecialization.ts(8,5): error TS2322: Type 'I1<number>' is not assignable to type 'I1<string>'.
|
|
Type 'number' is not assignable to type 'string'.
|
|
|
|
|
|
==== 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>
|
|
~~
|
|
!!! error TS2322: Type 'I1<number>' is not assignable to type 'I1<string>'.
|
|
!!! error TS2322: 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
|
|
|
|
|