2014-07-13 01:04:16 +02:00
|
|
|
//// [assignmentCompatability_checking-call-member-off-of-function-interface.ts]
|
|
|
|
// 3.8.4 Assignment Compatibility
|
|
|
|
|
|
|
|
interface Callable {
|
|
|
|
call(blah: any); // also works for 'apply'
|
|
|
|
}
|
|
|
|
|
|
|
|
var x: Callable;
|
|
|
|
|
|
|
|
// Should fail
|
|
|
|
x = '';
|
|
|
|
x = [''];
|
|
|
|
x = 4;
|
|
|
|
x = {};
|
|
|
|
|
|
|
|
// Should work
|
|
|
|
function f() { };
|
|
|
|
x = f;
|
|
|
|
|
|
|
|
function fn(c: Callable) { }
|
|
|
|
|
|
|
|
// Should Fail
|
|
|
|
fn('');
|
|
|
|
fn(['']);
|
|
|
|
fn(4);
|
|
|
|
fn({});
|
|
|
|
|
|
|
|
|
|
|
|
// Should work
|
|
|
|
fn(a => { });
|
|
|
|
|
|
|
|
|
|
|
|
//// [assignmentCompatability_checking-call-member-off-of-function-interface.js]
|
2014-08-19 19:43:13 +02:00
|
|
|
// 3.8.4 Assignment Compatibility
|
2014-07-13 01:04:16 +02:00
|
|
|
var x;
|
2014-08-16 00:49:09 +02:00
|
|
|
// Should fail
|
2014-07-13 01:04:16 +02:00
|
|
|
x = '';
|
|
|
|
x = [''];
|
|
|
|
x = 4;
|
|
|
|
x = {};
|
2014-08-14 15:21:30 +02:00
|
|
|
// Should work
|
2014-07-13 01:04:16 +02:00
|
|
|
function f() {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
x = f;
|
|
|
|
function fn(c) {
|
|
|
|
}
|
2014-08-16 00:49:09 +02:00
|
|
|
// Should Fail
|
2014-07-13 01:04:16 +02:00
|
|
|
fn('');
|
|
|
|
fn(['']);
|
|
|
|
fn(4);
|
|
|
|
fn({});
|
2014-08-16 00:49:09 +02:00
|
|
|
// Should work
|
2014-07-13 01:04:16 +02:00
|
|
|
fn(function (a) {
|
|
|
|
});
|