File: contextualTypingOfGenericFunctionTypedArguments1.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (31 lines) | stat: -rw-r--r-- 1,625 bytes parent folder | download | duplicates (7)
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
30
31
tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(16,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
  Type 'string' is not assignable to type 'Date'.
tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
  Type 'string' is not assignable to type 'Date'.


==== tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts (2 errors) ====
    interface Collection<T> {
        length: number;
        add(x: T): void;
        remove(x: T): boolean;
    }
    
    interface Combinators {
        forEach<T>(c: Collection<T>, f: (x: T) => Date): void;
    }
    
    var c2: Collection<number>;
    var _: Combinators;
    
    // errors on all 3 lines, bug was that r5 was the only line with errors
    var f = (x: number) => { return x.toFixed() };
    var r5 = _.forEach<number>(c2, f); 
                                   ~
!!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
!!! error TS2345:   Type 'string' is not assignable to type 'Date'.
    var r6 = _.forEach<number>(c2, (x) => { return x.toFixed() }); 
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
!!! error TS2345:   Type 'string' is not assignable to type 'Date'.