TypeScript/tests/baselines/reference/typesWithSpecializedConstructSignatures.types

119 lines
2.1 KiB
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/conformance/types/members/typesWithSpecializedConstructSignatures.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
constructor(x: 'hi');
>x : 'hi'
2014-08-15 23:33:16 +02:00
constructor(x: 'bye');
>x : 'bye'
2014-08-15 23:33:16 +02:00
constructor(x: string);
>x : string
2014-08-15 23:33:16 +02:00
constructor(x) {
>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('a');
>c : C
2014-08-15 23:33:16 +02:00
>new C('a') : C
>C : typeof C
2015-04-13 21:36:11 +02:00
>'a' : string
2014-08-15 23:33:16 +02:00
interface I {
>I : I
2014-08-15 23:33:16 +02:00
new(x: 'hi'): Derived1;
>x : 'hi'
>Derived1 : Derived1
2014-08-15 23:33:16 +02:00
new(x: 'bye'): Derived2;
>x : 'bye'
>Derived2 : Derived2
2014-08-15 23:33:16 +02:00
new(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 : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; }
2014-08-15 23:33:16 +02:00
new(x: 'hi'): Derived1;
>x : 'hi'
>Derived1 : Derived1
2014-08-15 23:33:16 +02:00
new(x: 'bye'): Derived2;
>x : 'bye'
>Derived2 : Derived2
2014-08-15 23:33:16 +02:00
new(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 : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; }
>c : C
>a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; }
2014-08-15 23:33:16 +02:00
i = a;
>i = a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; }
>i : I
>a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; }
2014-08-15 23:33:16 +02:00
a = i;
>a = i : I
>a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; }
>i : I
2014-08-15 23:33:16 +02:00
var r1 = new C('hi');
>r1 : C
2014-08-15 23:33:16 +02:00
>new C('hi') : C
>C : typeof C
2015-04-13 21:36:11 +02:00
>'hi' : string
2014-08-15 23:33:16 +02:00
var r2: Derived2 = new i('bye');
>r2 : Derived2
>Derived2 : Derived2
2014-08-15 23:33:16 +02:00
>new i('bye') : Derived2
>i : I
2015-04-13 21:36:11 +02:00
>'bye' : string
2014-08-15 23:33:16 +02:00
var r3: Base = new a('hm');
>r3 : Base
>Base : Base
2014-08-15 23:33:16 +02:00
>new a('hm') : Base
>a : { new (x: 'hi'): Derived1; new (x: 'bye'): Derived2; new (x: string): Base; }
2015-04-13 21:36:11 +02:00
>'hm' : string
2014-08-15 23:33:16 +02:00