32 lines
No EOL
1.2 KiB
Text
32 lines
No EOL
1.2 KiB
Text
==== tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts (5 errors) ====
|
|
interface I {
|
|
x1(a: number, callback: (x: 'hi') => number);
|
|
~~~~~~~~~~~~~~~~~~~
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
}
|
|
|
|
class C {
|
|
x1(a: number, callback: (x: 'hi') => number);
|
|
~~~~~~~~~~~~~~~~~~~
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
x1(a: number, callback: (x: string) => number) {
|
|
callback('hi');
|
|
callback('bye');
|
|
var hm = "hm";
|
|
callback(hm);
|
|
callback(1); // error
|
|
~
|
|
!!! Argument of type 'number' is not assignable to parameter of type 'string'.
|
|
}
|
|
}
|
|
|
|
var c: C;
|
|
c.x1(1, (x: 'hi') => { return 1; } );
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! A signature with an implementation cannot use a string literal type.
|
|
c.x1(1, (x: 'bye') => { return 1; } );
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! A signature with an implementation cannot use a string literal type.
|
|
c.x1(1, (x) => { return 1; } );
|
|
|
|
c.x1(1, (x: number) => { return 1; } ); |