File: genericCallWithOverloadedFunctionTypedArguments2.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 (43 lines) | stat: -rw-r--r-- 1,753 bytes parent folder | download
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
32
33
34
35
36
37
38
39
40
41
42
43
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedFunctionTypedArguments2.ts(28,20): error TS2345: Argument of type '<T>(x: T, y: T) => string' is not assignable to parameter of type '{ (x: {}): string; (x: {}, y?: {}): string; }'.


==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedFunctionTypedArguments2.ts (1 errors) ====
    // Function typed arguments with multiple signatures must be passed an implementation that matches all of them
    // Inferences are made quadratic-pairwise to and from these overload sets
    
    module NonGenericParameter {
        var a: {
            (x: boolean): boolean;
            (x: string): string;
        }
    
        function foo4(cb: typeof a) {
            return cb;
        }
    
        var r3 = foo4(<T, U>(x: T) => { var r: U; return r }); // ok
    }
    
    module GenericParameter {
        function foo5<T>(cb: { (x: T): string; (x: number): T }) {
            return cb;
        }
    
        var r6 = foo5(<T>(x: T) => x); // ok
    
        function foo6<T>(cb: { (x: T): string; (x: T, y?: T): string }) {
            return cb;
        }
    
        var r10 = foo6(<T>(x: T, y: T) => ''); // error
                       ~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, y: T) => string' is not assignable to parameter of type '{ (x: {}): string; (x: {}, y?: {}): string; }'.
    
        function foo7<T>(x:T, cb: { (x: T): string; (x: T, y?: T): string }) {
            return cb;
        }
    
        var r13 = foo7(1, <T>(x: T) => x); // ok
        var a: { <T>(x: T): number; <T>(x: number): T; }
        var r14 = foo7(1, a); // ok
    }