255 lines
11 KiB
Text
255 lines
11 KiB
Text
=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts ===
|
|
// Call signatures without a return type should infer one from the function body (if present)
|
|
|
|
// Simple types
|
|
function foo(x) {
|
|
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 3, 13))
|
|
|
|
return 1;
|
|
}
|
|
var r = foo(1);
|
|
>r : Symbol(r, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 6, 3))
|
|
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0))
|
|
|
|
function foo2(x) {
|
|
>foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 6, 15))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 8, 14))
|
|
|
|
return foo(x);
|
|
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 8, 14))
|
|
}
|
|
var r2 = foo2(1);
|
|
>r2 : Symbol(r2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 3))
|
|
>foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 6, 15))
|
|
|
|
function foo3() {
|
|
>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 17))
|
|
|
|
return foo3();
|
|
>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 17))
|
|
}
|
|
var r3 = foo3();
|
|
>r3 : Symbol(r3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 16, 3))
|
|
>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 17))
|
|
|
|
function foo4<T>(x: T) {
|
|
>foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 16, 16))
|
|
>T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 14))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 17))
|
|
>T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 14))
|
|
|
|
return x;
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 17))
|
|
}
|
|
var r4 = foo4(1);
|
|
>r4 : Symbol(r4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 21, 3))
|
|
>foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 16, 16))
|
|
|
|
function foo5(x) {
|
|
>foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 21, 17))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 23, 14))
|
|
|
|
if (true) {
|
|
return 1;
|
|
} else {
|
|
return 2;
|
|
}
|
|
}
|
|
var r5 = foo5(1);
|
|
>r5 : Symbol(r5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 30, 3))
|
|
>foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 21, 17))
|
|
|
|
function foo6(x) {
|
|
>foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 30, 17))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 32, 14))
|
|
|
|
try {
|
|
}
|
|
catch (e) {
|
|
>e : Symbol(e, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 35, 11))
|
|
|
|
return [];
|
|
}
|
|
finally {
|
|
return [];
|
|
}
|
|
}
|
|
var r6 = foo6(1);
|
|
>r6 : Symbol(r6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 42, 3))
|
|
>foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 30, 17))
|
|
|
|
function foo7(x) {
|
|
>foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 42, 17))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 44, 14))
|
|
|
|
return typeof x;
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 44, 14))
|
|
}
|
|
var r7 = foo7(1);
|
|
>r7 : Symbol(r7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 47, 3))
|
|
>foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 42, 17))
|
|
|
|
// object types
|
|
function foo8(x: number) {
|
|
>foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 47, 17))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 50, 14))
|
|
|
|
return { x: x };
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 51, 12))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 50, 14))
|
|
}
|
|
var r8 = foo8(1);
|
|
>r8 : Symbol(r8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 53, 3))
|
|
>foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 47, 17))
|
|
|
|
interface I {
|
|
>I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 53, 17))
|
|
|
|
foo: string;
|
|
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 55, 13))
|
|
}
|
|
function foo9(x: number) {
|
|
>foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 57, 1))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 58, 14))
|
|
|
|
var i: I;
|
|
>i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 59, 7))
|
|
>I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 53, 17))
|
|
|
|
return i;
|
|
>i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 59, 7))
|
|
}
|
|
var r9 = foo9(1);
|
|
>r9 : Symbol(r9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 62, 3))
|
|
>foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 57, 1))
|
|
|
|
class C {
|
|
>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 62, 17))
|
|
|
|
foo: string;
|
|
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 64, 9))
|
|
}
|
|
function foo10(x: number) {
|
|
>foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 66, 1))
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 67, 15))
|
|
|
|
var c: C;
|
|
>c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 68, 7))
|
|
>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 62, 17))
|
|
|
|
return c;
|
|
>c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 68, 7))
|
|
}
|
|
var r10 = foo10(1);
|
|
>r10 : Symbol(r10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 71, 3))
|
|
>foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 66, 1))
|
|
|
|
module M {
|
|
>M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 71, 19))
|
|
|
|
export var x = 1;
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 74, 14))
|
|
|
|
export class C { foo: string }
|
|
>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 74, 21))
|
|
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 75, 20))
|
|
}
|
|
function foo11() {
|
|
>foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 76, 1))
|
|
|
|
return M;
|
|
>M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 71, 19))
|
|
}
|
|
var r11 = foo11();
|
|
>r11 : Symbol(r11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 3))
|
|
>foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 76, 1))
|
|
|
|
// merged declarations
|
|
interface I2 {
|
|
>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 85, 1))
|
|
|
|
x: number;
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 83, 14))
|
|
}
|
|
interface I2 {
|
|
>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 85, 1))
|
|
|
|
y: number;
|
|
>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 86, 14))
|
|
}
|
|
function foo12() {
|
|
>foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 88, 1))
|
|
|
|
var i2: I2;
|
|
>i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 90, 7))
|
|
>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 85, 1))
|
|
|
|
return i2;
|
|
>i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 90, 7))
|
|
}
|
|
var r12 = foo12();
|
|
>r12 : Symbol(r12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 3))
|
|
>foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 88, 1))
|
|
|
|
function m1() { return 1; }
|
|
>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 95, 27))
|
|
|
|
module m1 { export var y = 2; }
|
|
>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 95, 27))
|
|
>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 22))
|
|
|
|
function foo13() {
|
|
>foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 31))
|
|
|
|
return m1;
|
|
>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 95, 27))
|
|
}
|
|
var r13 = foo13();
|
|
>r13 : Symbol(r13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 3))
|
|
>foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 31))
|
|
|
|
class c1 {
|
|
>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 1))
|
|
|
|
foo: string;
|
|
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 102, 10))
|
|
|
|
constructor(x) { }
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 104, 16))
|
|
}
|
|
module c1 {
|
|
>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 1))
|
|
|
|
export var x = 1;
|
|
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 107, 14))
|
|
}
|
|
function foo14() {
|
|
>foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 108, 1))
|
|
|
|
return c1;
|
|
>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 1))
|
|
}
|
|
var r14 = foo14();
|
|
>r14 : Symbol(r14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 3))
|
|
>foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 108, 1))
|
|
|
|
enum e1 { A }
|
|
>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 13))
|
|
>A : Symbol(e1.A, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 9))
|
|
|
|
module e1 { export var y = 1; }
|
|
>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 13))
|
|
>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 22))
|
|
|
|
function foo15() {
|
|
>foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 31))
|
|
|
|
return e1;
|
|
>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 13))
|
|
}
|
|
var r15 = foo15();
|
|
>r15 : Symbol(r15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 119, 3))
|
|
>foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 31))
|
|
|