2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts (8 errors) ====
|
|
|
|
// 3.8.4 Assignment Compatibility
|
|
|
|
|
|
|
|
interface Applicable {
|
|
|
|
apply(blah: any); // also works for 'apply'
|
|
|
|
}
|
|
|
|
|
|
|
|
var x: Applicable;
|
|
|
|
|
|
|
|
// Should fail
|
|
|
|
x = '';
|
|
|
|
~
|
|
|
|
!!! Type 'string' is not assignable to type 'Applicable':
|
|
|
|
!!! Property 'apply' is missing in type 'String'.
|
|
|
|
x = [''];
|
|
|
|
~
|
|
|
|
!!! Type 'string[]' is not assignable to type 'Applicable':
|
|
|
|
!!! Property 'apply' is missing in type 'string[]'.
|
|
|
|
x = 4;
|
|
|
|
~
|
|
|
|
!!! Type 'number' is not assignable to type 'Applicable':
|
|
|
|
!!! Property 'apply' is missing in type 'Number'.
|
|
|
|
x = {};
|
|
|
|
~
|
|
|
|
!!! Type '{}' is not assignable to type 'Applicable':
|
|
|
|
!!! Property 'apply' is missing in type '{}'.
|
|
|
|
|
|
|
|
// Should work
|
|
|
|
function f() { };
|
|
|
|
x = f;
|
|
|
|
|
|
|
|
function fn(c: Applicable) { }
|
|
|
|
|
|
|
|
// Should Fail
|
|
|
|
fn('');
|
2014-07-25 02:00:03 +02:00
|
|
|
~~
|
2014-07-25 04:39:50 +02:00
|
|
|
!!! Argument of type 'string' is not assignable to parameter of type 'Applicable'.
|
2014-07-13 01:04:16 +02:00
|
|
|
fn(['']);
|
2014-07-25 02:00:03 +02:00
|
|
|
~~~~
|
2014-07-25 04:39:50 +02:00
|
|
|
!!! Argument of type 'string[]' is not assignable to parameter of type 'Applicable'.
|
2014-07-13 01:04:16 +02:00
|
|
|
fn(4);
|
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 'Applicable'.
|
2014-07-13 01:04:16 +02:00
|
|
|
fn({});
|
2014-07-25 02:00:03 +02:00
|
|
|
~~
|
2014-07-25 04:39:50 +02:00
|
|
|
!!! Argument of type '{}' is not assignable to parameter of type 'Applicable'.
|
2014-07-25 02:00:03 +02:00
|
|
|
!!! Property 'apply' is missing in type '{}'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Should work
|
|
|
|
fn(a => { });
|
|
|
|
|