TypeScript/tests/baselines/reference/overloadingOnConstants2.errors.txt
2014-07-24 19:39:50 -07:00

36 lines
1.3 KiB
Plaintext

==== tests/cases/compiler/overloadingOnConstants2.ts (4 errors) ====
class C {
private x = 1;
}
class D extends C {}
class E {
private y = 1;
}
function foo(x: "hi", items: string[]): D;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Specialized overload signature is not assignable to any non-specialized signature.
function foo(x: "bye", items: string[]): E;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Specialized overload signature is not assignable to any non-specialized signature.
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
~~~~
!!! Argument of type 'string' is not assignable to parameter of type '"bye"'.
//function bar(x: "hi", items: string[]): D;
function bar(x: "bye", items: string[]): E;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Specialized overload signature is not assignable to any non-specialized signature.
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