2014-07-13 01:04:16 +02:00
|
|
|
//// [assignmentToObjectAndFunction.ts]
|
|
|
|
var errObj: Object = { toString: 0 }; // Error, incompatible toString
|
|
|
|
var goodObj: Object = {
|
|
|
|
toString(x?) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}; // Ok, because toString is a subtype of Object's toString
|
|
|
|
|
|
|
|
var errFun: Function = {}; // Error for no call signature
|
|
|
|
|
|
|
|
function foo() { }
|
|
|
|
module foo {
|
|
|
|
export var boom = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
var goodFundule: Function = foo; // ok
|
|
|
|
|
|
|
|
function bar() { }
|
|
|
|
module bar {
|
|
|
|
export function apply(thisArg: string, argArray?: string) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
var goodFundule2: Function = bar; // ok
|
|
|
|
|
|
|
|
function bad() { }
|
|
|
|
module bad {
|
|
|
|
export var apply = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
var badFundule: Function = bad; // error
|
|
|
|
|
|
|
|
//// [assignmentToObjectAndFunction.js]
|
2014-08-15 22:18:54 +02:00
|
|
|
var errObj = { toString: 0 }; // Error, incompatible toString
|
2014-07-13 01:04:16 +02:00
|
|
|
var goodObj = {
|
2014-07-23 20:48:29 +02:00
|
|
|
toString: function (x) {
|
2014-07-13 01:04:16 +02:00
|
|
|
return "";
|
|
|
|
}
|
2014-08-15 22:18:54 +02:00
|
|
|
}; // Ok, because toString is a subtype of Object's toString
|
|
|
|
var errFun = {}; // Error for no call signature
|
2015-02-07 03:45:09 +01:00
|
|
|
function foo() { }
|
2014-07-13 01:04:16 +02:00
|
|
|
var foo;
|
|
|
|
(function (foo) {
|
|
|
|
foo.boom = 0;
|
|
|
|
})(foo || (foo = {}));
|
2014-08-15 22:18:54 +02:00
|
|
|
var goodFundule = foo; // ok
|
2015-02-07 03:45:09 +01:00
|
|
|
function bar() { }
|
2014-07-13 01:04:16 +02:00
|
|
|
var bar;
|
|
|
|
(function (bar) {
|
2015-02-07 03:45:09 +01:00
|
|
|
function apply(thisArg, argArray) { }
|
2014-07-13 01:04:16 +02:00
|
|
|
bar.apply = apply;
|
|
|
|
})(bar || (bar = {}));
|
2014-08-15 22:18:54 +02:00
|
|
|
var goodFundule2 = bar; // ok
|
2015-02-07 03:45:09 +01:00
|
|
|
function bad() { }
|
2014-07-13 01:04:16 +02:00
|
|
|
var bad;
|
|
|
|
(function (bad) {
|
|
|
|
bad.apply = 0;
|
|
|
|
})(bad || (bad = {}));
|
2014-08-15 23:32:08 +02:00
|
|
|
var badFundule = bad; // error
|