36 lines
No EOL
1.3 KiB
Text
36 lines
No EOL
1.3 KiB
Text
==== 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 |