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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
tests/cases/compiler/overloadResolutionTest1.ts(7,18): error TS2769: No overload matches this call.
Overload 1 of 2, '(bar: { a: number; }[]): string', gave the following error.
Type 'string' is not assignable to type 'number'.
Overload 2 of 2, '(bar: { a: boolean; }[]): number', gave the following error.
Type 'string' is not assignable to type 'boolean'.
tests/cases/compiler/overloadResolutionTest1.ts(18,16): error TS2769: No overload matches this call.
Overload 1 of 2, '(bar: { a: number; }): string', gave the following error.
Type 'string' is not assignable to type 'number'.
Overload 2 of 2, '(bar: { a: boolean; }): number', gave the following error.
Type 'string' is not assignable to type 'boolean'.
tests/cases/compiler/overloadResolutionTest1.ts(24,15): error TS2769: No overload matches this call.
Overload 1 of 2, '(bar: { a: number; }): number', gave the following error.
Type 'boolean' is not assignable to type 'number'.
Overload 2 of 2, '(bar: { a: string; }): string', gave the following error.
Type 'boolean' is not assignable to type 'string'.
==== tests/cases/compiler/overloadResolutionTest1.ts (3 errors) ====
function foo(bar:{a:number;}[]):string;
function foo(bar:{a:boolean;}[]):number;
function foo(bar:{a:any;}[]):any{ return bar };
var x1 = foo([{a:true}]); // works
var x11 = foo([{a:0}]); // works
var x111 = foo([{a:"s"}]); // error - does not match any signature
~
!!! error TS2769: No overload matches this call.
!!! error TS2769: Overload 1 of 2, '(bar: { a: number; }[]): string', gave the following error.
!!! error TS2769: Type 'string' is not assignable to type 'number'.
!!! error TS2769: Overload 2 of 2, '(bar: { a: boolean; }[]): number', gave the following error.
!!! error TS2769: Type 'string' is not assignable to type 'boolean'.
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:1:19: The expected type comes from property 'a' which is declared here on type '{ a: number; }'
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:2:19: The expected type comes from property 'a' which is declared here on type '{ a: boolean; }'
!!! related TS2793 tests/cases/compiler/overloadResolutionTest1.ts:3:10: The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible.
var x1111 = foo([{a:null}]); // works - ambiguous call is resolved to be the first in the overload set so this returns a string
function foo2(bar:{a:number;}):string;
function foo2(bar:{a:boolean;}):number;
function foo2(bar:{a:any;}):any{ return bar };
var x2 = foo2({a:0}); // works
var x3 = foo2({a:true}); // works
var x4 = foo2({a:"s"}); // error
~
!!! error TS2769: No overload matches this call.
!!! error TS2769: Overload 1 of 2, '(bar: { a: number; }): string', gave the following error.
!!! error TS2769: Type 'string' is not assignable to type 'number'.
!!! error TS2769: Overload 2 of 2, '(bar: { a: boolean; }): number', gave the following error.
!!! error TS2769: Type 'string' is not assignable to type 'boolean'.
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:12:20: The expected type comes from property 'a' which is declared here on type '{ a: number; }'
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:13:20: The expected type comes from property 'a' which is declared here on type '{ a: boolean; }'
!!! related TS2793 tests/cases/compiler/overloadResolutionTest1.ts:14:10: The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible.
function foo4(bar:{a:number;}):number;
function foo4(bar:{a:string;}):string;
function foo4(bar:{a:any;}):any{ return bar };
var x = foo4({a:true}); // error
~
!!! error TS2769: No overload matches this call.
!!! error TS2769: Overload 1 of 2, '(bar: { a: number; }): number', gave the following error.
!!! error TS2769: Type 'boolean' is not assignable to type 'number'.
!!! error TS2769: Overload 2 of 2, '(bar: { a: string; }): string', gave the following error.
!!! error TS2769: Type 'boolean' is not assignable to type 'string'.
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:21:20: The expected type comes from property 'a' which is declared here on type '{ a: number; }'
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:22:20: The expected type comes from property 'a' which is declared here on type '{ a: string; }'
!!! related TS2793 tests/cases/compiler/overloadResolutionTest1.ts:23:10: The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible.
|