mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
152 lines
4.9 KiB
Plaintext
152 lines
4.9 KiB
Plaintext
//// [tests/cases/conformance/functions/functionImplementationErrors.ts] ////
|
|
|
|
=== 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))
|
|
}
|
|
|
|
declare var m: any;
|
|
>m : Symbol(m, Decl(functionImplementationErrors.ts, 27, 11))
|
|
|
|
// Function signature with parameter initializer referencing in scope local variable
|
|
function f6(n = m) {
|
|
>f6 : Symbol(f6, Decl(functionImplementationErrors.ts, 27, 19))
|
|
>n : Symbol(n, Decl(functionImplementationErrors.ts, 29, 12))
|
|
>m : Symbol(m, Decl(functionImplementationErrors.ts, 27, 11))
|
|
|
|
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))
|
|
|
|
};
|
|
|