2014-07-13 01:04:16 +02:00
|
|
|
//// [assignmentCompatability_checking-apply-member-off-of-function-interface.ts]
|
|
|
|
// 3.8.4 Assignment Compatibility
|
|
|
|
|
|
|
|
interface Applicable {
|
|
|
|
apply(blah: any); // also works for 'apply'
|
|
|
|
}
|
|
|
|
|
|
|
|
var x: Applicable;
|
|
|
|
|
|
|
|
// Should fail
|
|
|
|
x = '';
|
|
|
|
x = [''];
|
|
|
|
x = 4;
|
|
|
|
x = {};
|
|
|
|
|
|
|
|
// Should work
|
|
|
|
function f() { };
|
|
|
|
x = f;
|
|
|
|
|
|
|
|
function fn(c: Applicable) { }
|
|
|
|
|
|
|
|
// Should Fail
|
|
|
|
fn('');
|
|
|
|
fn(['']);
|
|
|
|
fn(4);
|
|
|
|
fn({});
|
|
|
|
|
|
|
|
|
|
|
|
// Should work
|
|
|
|
fn(a => { });
|
|
|
|
|
|
|
|
|
|
|
|
//// [assignmentCompatability_checking-apply-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) {
|
|
|
|
});
|