2014-07-13 01:04:16 +02:00
|
|
|
//// [returnStatements.ts]
|
|
|
|
// all the following should be valid
|
|
|
|
function fn1(): number { return 1; }
|
|
|
|
function fn2(): string { return ''; }
|
|
|
|
function fn3(): void { return undefined; }
|
|
|
|
function fn4(): void { return; }
|
|
|
|
function fn5(): boolean { return true; }
|
|
|
|
function fn6(): Date { return new Date(12); }
|
|
|
|
function fn7(): any { return null; }
|
|
|
|
function fn8(): any { return; } // OK, eq. to 'return undefined'
|
|
|
|
|
|
|
|
interface I { id: number }
|
|
|
|
class C implements I {
|
|
|
|
id: number;
|
|
|
|
dispose() {}
|
|
|
|
}
|
|
|
|
class D extends C {
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
function fn10(): I { return { id: 12 }; }
|
|
|
|
|
|
|
|
function fn11(): I { return new C(); }
|
|
|
|
function fn12(): C { return new D(); }
|
|
|
|
function fn13(): C { return null; }
|
|
|
|
|
|
|
|
|
|
|
|
//// [returnStatements.js]
|
|
|
|
var __extends = this.__extends || function (d, b) {
|
|
|
|
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
|
|
function __() { this.constructor = d; }
|
|
|
|
__.prototype = b.prototype;
|
|
|
|
d.prototype = new __();
|
|
|
|
};
|
2014-08-14 15:21:30 +02:00
|
|
|
// all the following should be valid
|
2015-02-07 05:03:24 +01:00
|
|
|
function fn1() { return 1; }
|
|
|
|
function fn2() { return ''; }
|
|
|
|
function fn3() { return undefined; }
|
|
|
|
function fn4() { return; }
|
|
|
|
function fn5() { return true; }
|
|
|
|
function fn6() { return new Date(12); }
|
|
|
|
function fn7() { return null; }
|
|
|
|
function fn8() { return; } // OK, eq. to 'return undefined'
|
2014-07-13 01:04:16 +02:00
|
|
|
var C = (function () {
|
|
|
|
function C() {
|
|
|
|
}
|
2015-02-07 03:45:09 +01:00
|
|
|
C.prototype.dispose = function () { };
|
2014-07-13 01:04:16 +02:00
|
|
|
return C;
|
|
|
|
})();
|
|
|
|
var D = (function (_super) {
|
|
|
|
__extends(D, _super);
|
|
|
|
function D() {
|
|
|
|
_super.apply(this, arguments);
|
|
|
|
}
|
|
|
|
return D;
|
|
|
|
})(C);
|
2015-02-07 05:03:24 +01:00
|
|
|
function fn10() { return { id: 12 }; }
|
|
|
|
function fn11() { return new C(); }
|
|
|
|
function fn12() { return new D(); }
|
|
|
|
function fn13() { return null; }
|