2014-07-13 01:04:16 +02:00
|
|
|
//// [functionImplementationErrors.ts]
|
|
|
|
// FunctionExpression with no return type annotation with multiple return statements with unrelated types
|
|
|
|
var f1 = function () {
|
|
|
|
return '';
|
|
|
|
return 3;
|
|
|
|
};
|
|
|
|
var f2 = function x() {
|
|
|
|
return '';
|
|
|
|
return 3;
|
|
|
|
};
|
|
|
|
var f3 = () => {
|
|
|
|
return '';
|
|
|
|
return 3;
|
|
|
|
};
|
|
|
|
|
|
|
|
// FunctionExpression with no return type annotation with return branch of number[] and other of string[]
|
|
|
|
var f4 = function () {
|
|
|
|
if (true) {
|
|
|
|
return [''];
|
|
|
|
} else {
|
|
|
|
return [1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function implemetnation with non -void return type annotation with no return
|
|
|
|
function f5(): number {
|
|
|
|
}
|
|
|
|
|
|
|
|
var m;
|
|
|
|
// Function signature with parameter initializer referencing in scope local variable
|
|
|
|
function f6(n = m) {
|
|
|
|
var m = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function signature with initializer referencing other parameter to the right
|
|
|
|
function f7(n = m, m?) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// FunctionExpression with non -void return type annotation with a throw, no return, and other code
|
|
|
|
// Should be error but isn't
|
|
|
|
undefined === function (): number {
|
|
|
|
throw undefined;
|
|
|
|
var x = 4;
|
|
|
|
};
|
2014-11-05 01:40:56 +01:00
|
|
|
|
|
|
|
class Base { private x; }
|
|
|
|
class AnotherClass { private y; }
|
|
|
|
class Derived1 extends Base { private m; }
|
|
|
|
class Derived2 extends Base { private n; }
|
|
|
|
function f8() {
|
|
|
|
return new Derived1();
|
|
|
|
return new Derived2();
|
|
|
|
}
|
|
|
|
var f9 = function () {
|
|
|
|
return new Derived1();
|
|
|
|
return new Derived2();
|
|
|
|
};
|
|
|
|
var f10 = () => {
|
|
|
|
return new Derived1();
|
|
|
|
return new Derived2();
|
|
|
|
};
|
|
|
|
function f11() {
|
|
|
|
return new Base();
|
|
|
|
return new AnotherClass();
|
|
|
|
}
|
|
|
|
var f12 = function () {
|
|
|
|
return new Base();
|
|
|
|
return new AnotherClass();
|
|
|
|
};
|
|
|
|
var f13 = () => {
|
|
|
|
return new Base();
|
|
|
|
return new AnotherClass();
|
|
|
|
};
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
//// [functionImplementationErrors.js]
|
2014-11-05 01:40:56 +01:00
|
|
|
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-12 00:54:12 +02:00
|
|
|
// FunctionExpression with no return type annotation with multiple return statements with unrelated types
|
2014-07-13 01:04:16 +02:00
|
|
|
var f1 = function () {
|
|
|
|
return '';
|
|
|
|
return 3;
|
|
|
|
};
|
|
|
|
var f2 = function x() {
|
|
|
|
return '';
|
|
|
|
return 3;
|
|
|
|
};
|
|
|
|
var f3 = function () {
|
|
|
|
return '';
|
|
|
|
return 3;
|
|
|
|
};
|
2014-08-12 00:54:12 +02:00
|
|
|
// FunctionExpression with no return type annotation with return branch of number[] and other of string[]
|
2014-07-13 01:04:16 +02:00
|
|
|
var f4 = function () {
|
|
|
|
if (true) {
|
|
|
|
return [''];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return [1];
|
|
|
|
}
|
|
|
|
};
|
2014-08-14 15:21:30 +02:00
|
|
|
// Function implemetnation with non -void return type annotation with no return
|
2014-07-13 01:04:16 +02:00
|
|
|
function f5() {
|
|
|
|
}
|
|
|
|
var m;
|
2014-08-14 15:21:30 +02:00
|
|
|
// Function signature with parameter initializer referencing in scope local variable
|
2014-07-13 01:04:16 +02:00
|
|
|
function f6(n) {
|
|
|
|
if (n === void 0) { n = m; }
|
|
|
|
var m = 4;
|
|
|
|
}
|
2014-08-14 15:21:30 +02:00
|
|
|
// Function signature with initializer referencing other parameter to the right
|
2014-07-13 01:04:16 +02:00
|
|
|
function f7(n, m) {
|
|
|
|
if (n === void 0) { n = m; }
|
|
|
|
}
|
2014-08-16 00:49:09 +02:00
|
|
|
// FunctionExpression with non -void return type annotation with a throw, no return, and other code
|
|
|
|
// Should be error but isn't
|
2014-07-13 01:04:16 +02:00
|
|
|
undefined === function () {
|
|
|
|
throw undefined;
|
|
|
|
var x = 4;
|
|
|
|
};
|
2014-11-05 01:40:56 +01:00
|
|
|
var Base = (function () {
|
|
|
|
function Base() {
|
|
|
|
}
|
|
|
|
return Base;
|
|
|
|
})();
|
|
|
|
var AnotherClass = (function () {
|
|
|
|
function AnotherClass() {
|
|
|
|
}
|
|
|
|
return AnotherClass;
|
|
|
|
})();
|
|
|
|
var Derived1 = (function (_super) {
|
|
|
|
__extends(Derived1, _super);
|
|
|
|
function Derived1() {
|
|
|
|
_super.apply(this, arguments);
|
|
|
|
}
|
|
|
|
return Derived1;
|
|
|
|
})(Base);
|
|
|
|
var Derived2 = (function (_super) {
|
|
|
|
__extends(Derived2, _super);
|
|
|
|
function Derived2() {
|
|
|
|
_super.apply(this, arguments);
|
|
|
|
}
|
|
|
|
return Derived2;
|
|
|
|
})(Base);
|
|
|
|
function f8() {
|
|
|
|
return new Derived1();
|
|
|
|
return new Derived2();
|
|
|
|
}
|
|
|
|
var f9 = function () {
|
|
|
|
return new Derived1();
|
|
|
|
return new Derived2();
|
|
|
|
};
|
|
|
|
var f10 = function () {
|
|
|
|
return new Derived1();
|
|
|
|
return new Derived2();
|
|
|
|
};
|
|
|
|
function f11() {
|
|
|
|
return new Base();
|
|
|
|
return new AnotherClass();
|
|
|
|
}
|
|
|
|
var f12 = function () {
|
|
|
|
return new Base();
|
|
|
|
return new AnotherClass();
|
|
|
|
};
|
|
|
|
var f13 = function () {
|
|
|
|
return new Base();
|
|
|
|
return new AnotherClass();
|
|
|
|
};
|