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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
=== tests/cases/conformance/functions/functionImplementationErrors.ts ===
// FunctionExpression with no return type annotation with multiple return statements with unrelated types
var f1 = function () {
>f1 : Symbol(f1, Decl(functionImplementationErrors.ts, 1, 3))
return '';
return 3;
};
var f2 = function x() {
>f2 : Symbol(f2, Decl(functionImplementationErrors.ts, 5, 3))
>x : Symbol(x, Decl(functionImplementationErrors.ts, 5, 8))
return '';
return 3;
};
var f3 = () => {
>f3 : Symbol(f3, Decl(functionImplementationErrors.ts, 9, 3))
return '';
return 3;
};
// FunctionExpression with no return type annotation with return branch of number[] and other of string[]
var f4 = function () {
>f4 : Symbol(f4, Decl(functionImplementationErrors.ts, 15, 3))
if (true) {
return [''];
} else {
return [1];
}
}
// Function implemetnation with non -void return type annotation with no return
function f5(): number {
>f5 : Symbol(f5, Decl(functionImplementationErrors.ts, 21, 1))
}
var m;
>m : Symbol(m, Decl(functionImplementationErrors.ts, 27, 3))
// Function signature with parameter initializer referencing in scope local variable
function f6(n = m) {
>f6 : Symbol(f6, Decl(functionImplementationErrors.ts, 27, 6))
>n : Symbol(n, Decl(functionImplementationErrors.ts, 29, 12))
>m : Symbol(m, Decl(functionImplementationErrors.ts, 30, 7))
var m = 4;
>m : Symbol(m, Decl(functionImplementationErrors.ts, 30, 7))
}
// Function signature with initializer referencing other parameter to the right
function f7(n = m, m?) {
>f7 : Symbol(f7, Decl(functionImplementationErrors.ts, 31, 1))
>n : Symbol(n, Decl(functionImplementationErrors.ts, 34, 12))
>m : Symbol(m, Decl(functionImplementationErrors.ts, 34, 18))
>m : Symbol(m, Decl(functionImplementationErrors.ts, 34, 18))
}
// FunctionExpression with non -void return type annotation with a throw, no return, and other code
// Should be error but isn't
undefined === function (): number {
>undefined : Symbol(undefined)
throw undefined;
>undefined : Symbol(undefined)
var x = 4;
>x : Symbol(x, Decl(functionImplementationErrors.ts, 41, 7))
};
class Base { private x; }
>Base : Symbol(Base, Decl(functionImplementationErrors.ts, 42, 2))
>x : Symbol(Base.x, Decl(functionImplementationErrors.ts, 44, 12))
class AnotherClass { private y; }
>AnotherClass : Symbol(AnotherClass, Decl(functionImplementationErrors.ts, 44, 25))
>y : Symbol(AnotherClass.y, Decl(functionImplementationErrors.ts, 45, 20))
class Derived1 extends Base { private m; }
>Derived1 : Symbol(Derived1, Decl(functionImplementationErrors.ts, 45, 33))
>Base : Symbol(Base, Decl(functionImplementationErrors.ts, 42, 2))
>m : Symbol(Derived1.m, Decl(functionImplementationErrors.ts, 46, 29))
class Derived2 extends Base { private n; }
>Derived2 : Symbol(Derived2, Decl(functionImplementationErrors.ts, 46, 42))
>Base : Symbol(Base, Decl(functionImplementationErrors.ts, 42, 2))
>n : Symbol(Derived2.n, Decl(functionImplementationErrors.ts, 47, 29))
function f8() {
>f8 : Symbol(f8, Decl(functionImplementationErrors.ts, 47, 42))
return new Derived1();
>Derived1 : Symbol(Derived1, Decl(functionImplementationErrors.ts, 45, 33))
return new Derived2();
>Derived2 : Symbol(Derived2, Decl(functionImplementationErrors.ts, 46, 42))
}
var f9 = function () {
>f9 : Symbol(f9, Decl(functionImplementationErrors.ts, 52, 3))
return new Derived1();
>Derived1 : Symbol(Derived1, Decl(functionImplementationErrors.ts, 45, 33))
return new Derived2();
>Derived2 : Symbol(Derived2, Decl(functionImplementationErrors.ts, 46, 42))
};
var f10 = () => {
>f10 : Symbol(f10, Decl(functionImplementationErrors.ts, 56, 3))
return new Derived1();
>Derived1 : Symbol(Derived1, Decl(functionImplementationErrors.ts, 45, 33))
return new Derived2();
>Derived2 : Symbol(Derived2, Decl(functionImplementationErrors.ts, 46, 42))
};
function f11() {
>f11 : Symbol(f11, Decl(functionImplementationErrors.ts, 59, 2))
return new Base();
>Base : Symbol(Base, Decl(functionImplementationErrors.ts, 42, 2))
return new AnotherClass();
>AnotherClass : Symbol(AnotherClass, Decl(functionImplementationErrors.ts, 44, 25))
}
var f12 = function () {
>f12 : Symbol(f12, Decl(functionImplementationErrors.ts, 64, 3))
return new Base();
>Base : Symbol(Base, Decl(functionImplementationErrors.ts, 42, 2))
return new AnotherClass();
>AnotherClass : Symbol(AnotherClass, Decl(functionImplementationErrors.ts, 44, 25))
};
var f13 = () => {
>f13 : Symbol(f13, Decl(functionImplementationErrors.ts, 68, 3))
return new Base();
>Base : Symbol(Base, Decl(functionImplementationErrors.ts, 42, 2))
return new AnotherClass();
>AnotherClass : Symbol(AnotherClass, Decl(functionImplementationErrors.ts, 44, 25))
};
|