TypeScript/tests/baselines/reference/typesWithSpecializedCallSignatures.types

148 lines
3.4 KiB
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/conformance/types/members/typesWithSpecializedCallSignatures.ts ===
// basic uses of specialized signatures without errors
class Base { foo: string }
>Base : Base
>foo : string
2014-08-15 23:33:16 +02:00
class Derived1 extends Base { bar: string }
>Derived1 : Derived1
>Base : Base
>bar : string
2014-08-15 23:33:16 +02:00
class Derived2 extends Base { baz: string }
>Derived2 : Derived2
>Base : Base
>baz : string
2014-08-15 23:33:16 +02:00
class C {
>C : C
2014-08-15 23:33:16 +02:00
foo(x: 'hi'): Derived1;
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : 'hi'
>Derived1 : Derived1
2014-08-15 23:33:16 +02:00
foo(x: 'bye'): Derived2;
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : 'bye'
>Derived2 : Derived2
2014-08-15 23:33:16 +02:00
foo(x: string): Base;
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : string
>Base : Base
2014-08-15 23:33:16 +02:00
foo(x) {
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : any
2014-08-15 23:33:16 +02:00
return x;
>x : any
2014-08-15 23:33:16 +02:00
}
}
var c = new C();
>c : C
2014-08-15 23:33:16 +02:00
>new C() : C
>C : typeof C
2014-08-15 23:33:16 +02:00
interface I {
>I : I
2014-08-15 23:33:16 +02:00
foo(x: 'hi'): Derived1;
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : 'hi'
>Derived1 : Derived1
2014-08-15 23:33:16 +02:00
foo(x: 'bye'): Derived2;
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : 'bye'
>Derived2 : Derived2
2014-08-15 23:33:16 +02:00
foo(x: string): Base;
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : string
>Base : Base
2014-08-15 23:33:16 +02:00
}
var i: I;
>i : I
>I : I
2014-08-15 23:33:16 +02:00
var a: {
>a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; }
2014-08-15 23:33:16 +02:00
foo(x: 'hi'): Derived1;
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : 'hi'
>Derived1 : Derived1
2014-08-15 23:33:16 +02:00
foo(x: 'bye'): Derived2;
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : 'bye'
>Derived2 : Derived2
2014-08-15 23:33:16 +02:00
foo(x: string): Base;
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>x : string
>Base : Base
2014-08-15 23:33:16 +02:00
};
c = i;
>c = i : I
>c : C
>i : I
2014-08-15 23:33:16 +02:00
c = a;
>c = a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; }
>c : C
>a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; }
2014-08-15 23:33:16 +02:00
i = c;
>i = c : C
>i : I
>c : C
2014-08-15 23:33:16 +02:00
i = a;
>i = a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; }
>i : I
>a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; }
2014-08-15 23:33:16 +02:00
a = c;
>a = c : C
>a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; }
>c : C
2014-08-15 23:33:16 +02:00
a = i;
>a = i : I
>a : { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; }
>i : I
2014-08-15 23:33:16 +02:00
var r1: Derived1 = c.foo('hi');
>r1 : Derived1
>Derived1 : Derived1
2014-08-15 23:33:16 +02:00
>c.foo('hi') : Derived1
>c.foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>c : C
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
2015-04-13 21:36:11 +02:00
>'hi' : string
2014-08-15 23:33:16 +02:00
var r2: Derived2 = c.foo('bye');
>r2 : Derived2
>Derived2 : Derived2
2014-08-15 23:33:16 +02:00
>c.foo('bye') : Derived2
>c.foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>c : C
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
2015-04-13 21:36:11 +02:00
>'bye' : string
2014-08-15 23:33:16 +02:00
var r3: Base = c.foo('hm');
>r3 : Base
>Base : Base
2014-08-15 23:33:16 +02:00
>c.foo('hm') : Base
>c.foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
>c : C
>foo : { (x: 'hi'): Derived1; (x: 'bye'): Derived2; (x: string): Base; }
2015-04-13 21:36:11 +02:00
>'hm' : string
2014-08-15 23:33:16 +02:00