51 lines
658 B
JavaScript
51 lines
658 B
JavaScript
|
//// [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]
|
||
|
var x;
|
||
|
x = '';
|
||
|
x = [''];
|
||
|
x = 4;
|
||
|
x = {};
|
||
|
function f() {
|
||
|
}
|
||
|
;
|
||
|
x = f;
|
||
|
function fn(c) {
|
||
|
}
|
||
|
fn('');
|
||
|
fn(['']);
|
||
|
fn(4);
|
||
|
fn({});
|
||
|
fn(function (a) {
|
||
|
});
|