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
|
tests/cases/compiler/overloadingOnConstants2.ts(9,10): error TS2394: Overload signature is not compatible with function implementation.
tests/cases/compiler/overloadingOnConstants2.ts(15,13): error TS2345: Argument of type '"um"' is not assignable to parameter of type '"bye"'.
tests/cases/compiler/overloadingOnConstants2.ts(19,10): error TS2394: Overload signature is not compatible with function implementation.
==== tests/cases/compiler/overloadingOnConstants2.ts (3 errors) ====
class C {
private x = 1;
}
class D extends C {}
class E {
private y = 1;
}
function foo(x: "hi", items: string[]): D;
function foo(x: "bye", items: string[]): E;
~~~
!!! error TS2394: Overload signature is not compatible with function implementation.
function foo(x: string, items: string[]): C {
return null;
}
var a: D = foo("hi", []); // D
var b: E = foo("bye", []); // E
var c = foo("um", []); // error
~~~~
!!! error TS2345: Argument of type '"um"' is not assignable to parameter of type '"bye"'.
//function bar(x: "hi", items: string[]): D;
function bar(x: "bye", items: string[]): E;
~~~
!!! error TS2394: Overload signature is not compatible with function implementation.
function bar(x: string, items: string[]): C;
function bar(x: string, items: string[]): C {
return null;
}
var d: D = bar("hi", []); // D
var e: E = bar("bye", []); // E
var f: C = bar("um", []); // C
|