2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/overloadOnConstNoAnyImplementation.ts (4 errors) ====
|
|
|
|
function x1(a: number, cb: (x: 'hi') => number);
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
|
|
function x1(a: number, cb: (x: 'bye') => number);
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
|
|
function x1(a: number, cb: (x: string) => number) {
|
|
|
|
cb('hi');
|
|
|
|
cb('bye');
|
|
|
|
var hm = 'hm';
|
|
|
|
cb(hm);
|
|
|
|
cb('uh');
|
|
|
|
cb(1); // error
|
2014-07-25 02:00:03 +02:00
|
|
|
~
|
2014-07-25 04:39:50 +02:00
|
|
|
!!! Argument of type 'number' is not assignable to parameter of type 'string'.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var cb: (number) => number = (x: number) => 1;
|
|
|
|
x1(1, cb);
|
|
|
|
x1(1, (x: 'hi') => 1); // error
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
!!! A signature with an implementation cannot use a string literal type.
|
|
|
|
x1(1, (x: string) => 1);
|