TypeScript/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.errors.txt
2014-07-24 19:39:50 -07:00

52 lines
1.4 KiB
Plaintext

==== 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 = '';
~
!!! Type 'string' is not assignable to type 'Callable':
!!! Property 'call' is missing in type 'String'.
x = [''];
~
!!! Type 'string[]' is not assignable to type 'Callable':
!!! Property 'call' is missing in type 'string[]'.
x = 4;
~
!!! Type 'number' is not assignable to type 'Callable':
!!! Property 'call' is missing in type 'Number'.
x = {};
~
!!! Type '{}' is not assignable to type 'Callable':
!!! Property 'call' is missing in type '{}'.
// Should work
function f() { };
x = f;
function fn(c: Callable) { }
// Should Fail
fn('');
~~
!!! Argument of type 'string' is not assignable to parameter of type 'Callable'.
fn(['']);
~~~~
!!! Argument of type 'string[]' is not assignable to parameter of type 'Callable'.
fn(4);
~
!!! Argument of type 'number' is not assignable to parameter of type 'Callable'.
fn({});
~~
!!! Argument of type '{}' is not assignable to parameter of type 'Callable'.
!!! Property 'call' is missing in type '{}'.
// Should work
fn(a => { });