2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithOptionalParameters.ts ===
|
|
|
|
// Optional parameters should be valid in all the below casts
|
|
|
|
|
|
|
|
function foo(x?: number) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo : (x?: number) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : number
|
|
|
|
|
|
|
|
var f = function foo(x?: number) { }
|
|
|
|
>f : (x?: number) => void
|
|
|
|
>function foo(x?: number) { } : (x?: number) => void
|
|
|
|
>foo : (x?: number) => void
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
var f2 = (x: number, y?: number) => { }
|
|
|
|
>f2 : (x: number, y?: number) => void
|
|
|
|
>(x: number, y?: number) => { } : (x: number, y?: number) => void
|
|
|
|
>x : number
|
|
|
|
>y : number
|
|
|
|
|
|
|
|
foo(1);
|
|
|
|
>foo(1) : void
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo : (x?: number) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
foo();
|
|
|
|
>foo() : void
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo : (x?: number) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
f(1);
|
|
|
|
>f(1) : void
|
|
|
|
>f : (x?: number) => void
|
|
|
|
|
|
|
|
f();
|
|
|
|
>f() : void
|
|
|
|
>f : (x?: number) => void
|
|
|
|
|
|
|
|
f2(1);
|
|
|
|
>f2(1) : void
|
|
|
|
>f2 : (x: number, y?: number) => void
|
|
|
|
|
|
|
|
f2(1, 2);
|
|
|
|
>f2(1, 2) : void
|
|
|
|
>f2 : (x: number, y?: number) => void
|
|
|
|
|
|
|
|
class C {
|
|
|
|
>C : C
|
|
|
|
|
|
|
|
foo(x?: number) { }
|
|
|
|
>foo : (x?: number) => void
|
|
|
|
>x : number
|
|
|
|
}
|
|
|
|
|
|
|
|
var c: C;
|
|
|
|
>c : C
|
|
|
|
>C : C
|
|
|
|
|
|
|
|
c.foo();
|
|
|
|
>c.foo() : void
|
|
|
|
>c.foo : (x?: number) => void
|
|
|
|
>c : C
|
|
|
|
>foo : (x?: number) => void
|
|
|
|
|
|
|
|
c.foo(1);
|
|
|
|
>c.foo(1) : void
|
|
|
|
>c.foo : (x?: number) => void
|
|
|
|
>c : C
|
|
|
|
>foo : (x?: number) => void
|
|
|
|
|
|
|
|
interface I {
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
(x?: number);
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
foo(x: number, y?: number);
|
|
|
|
>foo : (x: number, y?: number) => any
|
|
|
|
>x : number
|
|
|
|
>y : number
|
|
|
|
}
|
|
|
|
|
|
|
|
var i: I;
|
|
|
|
>i : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
i();
|
|
|
|
>i() : any
|
|
|
|
>i : I
|
|
|
|
|
|
|
|
i(1);
|
|
|
|
>i(1) : any
|
|
|
|
>i : I
|
|
|
|
|
|
|
|
i.foo(1);
|
|
|
|
>i.foo(1) : any
|
|
|
|
>i.foo : (x: number, y?: number) => any
|
|
|
|
>i : I
|
|
|
|
>foo : (x: number, y?: number) => any
|
|
|
|
|
|
|
|
i.foo(1, 2);
|
|
|
|
>i.foo(1, 2) : any
|
|
|
|
>i.foo : (x: number, y?: number) => any
|
|
|
|
>i : I
|
|
|
|
>foo : (x: number, y?: number) => any
|
|
|
|
|
|
|
|
var a: {
|
|
|
|
>a : { (x?: number): any; foo(x?: number): any; }
|
|
|
|
|
|
|
|
(x?: number);
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
foo(x?: number);
|
|
|
|
>foo : (x?: number) => any
|
|
|
|
>x : number
|
|
|
|
}
|
|
|
|
|
|
|
|
a();
|
|
|
|
>a() : any
|
|
|
|
>a : { (x?: number): any; foo(x?: number): any; }
|
|
|
|
|
|
|
|
a(1);
|
|
|
|
>a(1) : any
|
|
|
|
>a : { (x?: number): any; foo(x?: number): any; }
|
|
|
|
|
|
|
|
a.foo();
|
|
|
|
>a.foo() : any
|
|
|
|
>a.foo : (x?: number) => any
|
|
|
|
>a : { (x?: number): any; foo(x?: number): any; }
|
|
|
|
>foo : (x?: number) => any
|
|
|
|
|
|
|
|
a.foo(1);
|
|
|
|
>a.foo(1) : any
|
|
|
|
>a.foo : (x?: number) => any
|
|
|
|
>a : { (x?: number): any; foo(x?: number): any; }
|
|
|
|
>foo : (x?: number) => any
|
|
|
|
|
|
|
|
var b = {
|
2014-12-03 12:05:37 +01:00
|
|
|
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
|
|
|
|
>{ foo(x?: number) { }, a: function foo(x: number, y?: number) { }, b: (x?: number) => { }} : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
foo(x?: number) { },
|
|
|
|
>foo : (x?: number) => void
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
a: function foo(x: number, y?: number) { },
|
|
|
|
>a : (x: number, y?: number) => void
|
|
|
|
>function foo(x: number, y?: number) { } : (x: number, y?: number) => void
|
|
|
|
>foo : (x: number, y?: number) => void
|
|
|
|
>x : number
|
|
|
|
>y : number
|
|
|
|
|
|
|
|
b: (x?: number) => { }
|
|
|
|
>b : (x?: number) => void
|
|
|
|
>(x?: number) => { } : (x?: number) => void
|
|
|
|
>x : number
|
|
|
|
}
|
|
|
|
|
|
|
|
b.foo();
|
|
|
|
>b.foo() : void
|
|
|
|
>b.foo : (x?: number) => void
|
2014-12-03 12:05:37 +01:00
|
|
|
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>foo : (x?: number) => void
|
|
|
|
|
|
|
|
b.foo(1);
|
|
|
|
>b.foo(1) : void
|
|
|
|
>b.foo : (x?: number) => void
|
2014-12-03 12:05:37 +01:00
|
|
|
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>foo : (x?: number) => void
|
|
|
|
|
|
|
|
b.a(1);
|
|
|
|
>b.a(1) : void
|
|
|
|
>b.a : (x: number, y?: number) => void
|
2014-12-03 12:05:37 +01:00
|
|
|
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : (x: number, y?: number) => void
|
|
|
|
|
|
|
|
b.a(1, 2);
|
|
|
|
>b.a(1, 2) : void
|
|
|
|
>b.a : (x: number, y?: number) => void
|
2014-12-03 12:05:37 +01:00
|
|
|
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : (x: number, y?: number) => void
|
|
|
|
|
|
|
|
b.b();
|
|
|
|
>b.b() : void
|
|
|
|
>b.b : (x?: number) => void
|
2014-12-03 12:05:37 +01:00
|
|
|
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>b : (x?: number) => void
|
|
|
|
|
|
|
|
b.b(1);
|
|
|
|
>b.b(1) : void
|
|
|
|
>b.b : (x?: number) => void
|
2014-12-03 12:05:37 +01:00
|
|
|
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>b : (x?: number) => void
|
|
|
|
|