1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
tests/cases/compiler/fixingTypeParametersRepeatedly2.ts(11,32): error TS2741: Property 'toBase' is missing in type 'Base' but required in type 'Derived'.
tests/cases/compiler/fixingTypeParametersRepeatedly2.ts(17,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'result' must be of type 'Derived', but here has type 'Base'.
==== tests/cases/compiler/fixingTypeParametersRepeatedly2.ts (2 errors) ====
interface Base {
baseProp;
}
interface Derived extends Base {
toBase(): Base;
}
var derived: Derived;
declare function foo<T>(x: T, func: (p: T) => T): T;
var result = foo(derived, d => d.toBase());
~~~~~~~~~~
!!! error TS2741: Property 'toBase' is missing in type 'Base' but required in type 'Derived'.
!!! related TS2728 tests/cases/compiler/fixingTypeParametersRepeatedly2.ts:5:5: 'toBase' is declared here.
!!! related TS6502 tests/cases/compiler/fixingTypeParametersRepeatedly2.ts:10:37: The expected type comes from the return type of this signature.
// bar should type check just like foo.
// The same error should be observed in both cases.
declare function bar<T>(x: T, func: (p: T) => T): T;
declare function bar<T>(x: T, func: (p: T) => T): T;
var result = bar(derived, d => d.toBase());
~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'result' must be of type 'Derived', but here has type 'Base'.
!!! related TS6203 tests/cases/compiler/fixingTypeParametersRepeatedly2.ts:11:5: 'result' was also declared here.
|