File: fixingTypeParametersRepeatedly2.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (29 lines) | stat: -rw-r--r-- 1,657 bytes parent folder | download | duplicates (4)
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.