-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
functionImplementationErrors.1.normal.js
99 lines (99 loc) · 2.66 KB
/
functionImplementationErrors.1.normal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//// [functionImplementationErrors.ts]
// FunctionExpression with no return type annotation with multiple return statements with unrelated types
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
import _inherits from "@swc/helpers/src/_inherits.mjs";
import _create_super from "@swc/helpers/src/_create_super.mjs";
var f1 = function f1() {
return "";
return 3;
};
var f2 = function x() {
return "";
return 3;
};
var f3 = function() {
return "";
return 3;
};
// FunctionExpression with no return type annotation with return branch of number[] and other of string[]
var f4 = function f4() {
if (true) {
return [
""
];
} else {
return [
1
];
}
};
// Function implemetnation with non -void return type annotation with no return
function f5() {}
var m;
// Function signature with parameter initializer referencing in scope local variable
function f6() {
var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : m;
var m1 = 4;
}
// Function signature with initializer referencing other parameter to the right
function f7() {
var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : m, m = arguments.length > 1 ? arguments[1] : void 0;
}
// FunctionExpression with non -void return type annotation with a throw, no return, and other code
// Should be error but isn't
undefined === function() {
throw undefined;
var x = 4;
};
var Base = function Base() {
"use strict";
_class_call_check(this, Base);
};
var AnotherClass = function AnotherClass() {
"use strict";
_class_call_check(this, AnotherClass);
};
var Derived1 = /*#__PURE__*/ function(Base) {
"use strict";
_inherits(Derived1, Base);
var _super = _create_super(Derived1);
function Derived1() {
_class_call_check(this, Derived1);
return _super.apply(this, arguments);
}
return Derived1;
}(Base);
var Derived2 = /*#__PURE__*/ function(Base) {
"use strict";
_inherits(Derived2, Base);
var _super = _create_super(Derived2);
function Derived2() {
_class_call_check(this, Derived2);
return _super.apply(this, arguments);
}
return Derived2;
}(Base);
function f8() {
return new Derived1();
return new Derived2();
}
var f9 = function f9() {
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 f12() {
return new Base();
return new AnotherClass();
};
var f13 = function() {
return new Base();
return new AnotherClass();
};