67 lines
No EOL
3.3 KiB
Text
67 lines
No EOL
3.3 KiB
Text
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(10,1): error TS2322: Type 'string' is not assignable to type 'Callable':
|
|
Property 'call' is missing in type 'String'.
|
|
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(11,1): error TS2322: Type 'string[]' is not assignable to type 'Callable':
|
|
Property 'call' is missing in type 'string[]'.
|
|
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(12,1): error TS2322: Type 'number' is not assignable to type 'Callable':
|
|
Property 'call' is missing in type 'Number'.
|
|
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(13,1): error TS2322: Type '{}' is not assignable to type 'Callable':
|
|
Property 'call' is missing in type '{}'.
|
|
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Callable'.
|
|
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(23,4): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'Callable'.
|
|
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(24,4): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Callable'.
|
|
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(25,4): error TS2345: Argument of type '{}' is not assignable to parameter of type 'Callable'.
|
|
Property 'call' is missing in type '{}'.
|
|
|
|
|
|
==== tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts (8 errors) ====
|
|
// 3.8.4 Assignment Compatibility
|
|
|
|
interface Callable {
|
|
call(blah: any); // also works for 'apply'
|
|
}
|
|
|
|
var x: Callable;
|
|
|
|
// Should fail
|
|
x = '';
|
|
~
|
|
!!! error TS2322: Type 'string' is not assignable to type 'Callable':
|
|
!!! error TS2322: Property 'call' is missing in type 'String'.
|
|
x = [''];
|
|
~
|
|
!!! error TS2322: Type 'string[]' is not assignable to type 'Callable':
|
|
!!! error TS2322: Property 'call' is missing in type 'string[]'.
|
|
x = 4;
|
|
~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'Callable':
|
|
!!! error TS2322: Property 'call' is missing in type 'Number'.
|
|
x = {};
|
|
~
|
|
!!! error TS2322: Type '{}' is not assignable to type 'Callable':
|
|
!!! error TS2322: Property 'call' is missing in type '{}'.
|
|
|
|
// Should work
|
|
function f() { };
|
|
x = f;
|
|
|
|
function fn(c: Callable) { }
|
|
|
|
// Should Fail
|
|
fn('');
|
|
~~
|
|
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Callable'.
|
|
fn(['']);
|
|
~~~~
|
|
!!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'Callable'.
|
|
fn(4);
|
|
~
|
|
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Callable'.
|
|
fn({});
|
|
~~
|
|
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'Callable'.
|
|
!!! error TS2345: Property 'call' is missing in type '{}'.
|
|
|
|
|
|
// Should work
|
|
fn(a => { });
|
|
|