TypeScript/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.types
2015-04-15 16:44:20 -07:00

263 lines
6.6 KiB
Plaintext

=== tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.ts ===
// Two call or construct signatures are considered identical when they have the same number of type parameters and, considering those
// parameters pairwise identical, have identical type parameter constraints, identical number of parameters with identical kind(required,
// optional or rest) and types, and identical return types.
class B<T> {
>B : B<T>
>T : T
constructor(x: T, y?: T) { return null; }
>x : T
>T : T
>y : T
>T : T
>null : null
}
class C<T> {
>C : C<T>
>T : T
constructor(x: T, y?: T) { return null; }
>x : T
>T : T
>y : T
>T : T
>null : null
}
interface I<T> {
>I : I<T>
>T : T
new(x: T, y?: T): B<T>;
>x : T
>T : T
>y : T
>T : T
>B : B<T>
>T : T
}
interface I2 {
>I2 : I2
new<T>(x: T, y?: T): C<T>;
>T : T
>x : T
>T : T
>y : T
>T : T
>C : C<T>
>T : T
}
var a: { new<T>(x: T, y?: T): B<T> }
>a : new <T>(x: T, y?: T) => B<T>
>T : T
>x : T
>T : T
>y : T
>T : T
>B : B<T>
>T : T
var b = { new<T>(x: T, y?: T) { return new C<T>(x, y); } }; // not a construct signature, function called new
>b : { new<T>(x: T, y?: T): C<T>; }
>{ new<T>(x: T, y?: T) { return new C<T>(x, y); } } : { new<T>(x: T, y?: T): C<T>; }
>new : <T>(x: T, y?: T) => C<T>
>T : T
>x : T
>T : T
>y : T
>T : T
>new C<T>(x, y) : C<T>
>C : typeof C
>T : T
>x : T
>y : T
function foo1b(x: B<string>);
>foo1b : { (x: B<string>): any; (x: B<string>): any; }
>x : B<string>
>B : B<T>
function foo1b(x: B<string>); // error
>foo1b : { (x: B<string>): any; (x: B<string>): any; }
>x : B<string>
>B : B<T>
function foo1b(x: any) { }
>foo1b : { (x: B<string>): any; (x: B<string>): any; }
>x : any
function foo1c(x: C<string>);
>foo1c : { (x: C<string>): any; (x: C<string>): any; }
>x : C<string>
>C : C<T>
function foo1c(x: C<string>); // error
>foo1c : { (x: C<string>): any; (x: C<string>): any; }
>x : C<string>
>C : C<T>
function foo1c(x: any) { }
>foo1c : { (x: C<string>): any; (x: C<string>): any; }
>x : any
function foo2(x: I<string>);
>foo2 : { (x: I<string>): any; (x: I<string>): any; }
>x : I<string>
>I : I<T>
function foo2(x: I<string>); // error
>foo2 : { (x: I<string>): any; (x: I<string>): any; }
>x : I<string>
>I : I<T>
function foo2(x: any) { }
>foo2 : { (x: I<string>): any; (x: I<string>): any; }
>x : any
function foo3(x: typeof a);
>foo3 : { (x: new <T>(x: T, y?: T) => B<T>): any; (x: new <T>(x: T, y?: T) => B<T>): any; }
>x : new <T>(x: T, y?: T) => B<T>
>a : new <T>(x: T, y?: T) => B<T>
function foo3(x: typeof a); // error
>foo3 : { (x: new <T>(x: T, y?: T) => B<T>): any; (x: new <T>(x: T, y?: T) => B<T>): any; }
>x : new <T>(x: T, y?: T) => B<T>
>a : new <T>(x: T, y?: T) => B<T>
function foo3(x: any) { }
>foo3 : { (x: new <T>(x: T, y?: T) => B<T>): any; (x: new <T>(x: T, y?: T) => B<T>): any; }
>x : any
function foo4(x: typeof b);
>foo4 : { (x: { new<T>(x: T, y?: T): C<T>; }): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
>x : { new<T>(x: T, y?: T): C<T>; }
>b : { new<T>(x: T, y?: T): C<T>; }
function foo4(x: typeof b); // error
>foo4 : { (x: { new<T>(x: T, y?: T): C<T>; }): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
>x : { new<T>(x: T, y?: T): C<T>; }
>b : { new<T>(x: T, y?: T): C<T>; }
function foo4(x: any) { }
>foo4 : { (x: { new<T>(x: T, y?: T): C<T>; }): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
>x : any
function foo8(x: B<string>): string;
>foo8 : { (x: B<string>): string; (x: I<string>): number; }
>x : B<string>
>B : B<T>
function foo8(x: I<string>): number; // BUG 832086
>foo8 : { (x: B<string>): string; (x: I<string>): number; }
>x : I<string>
>I : I<T>
function foo8(x: any): any { }
>foo8 : { (x: B<string>): string; (x: I<string>): number; }
>x : any
function foo9(x: B<string>);
>foo9 : { (x: B<string>): any; (x: C<string>): any; }
>x : B<string>
>B : B<T>
function foo9(x: C<string>); // error, differ only by return type
>foo9 : { (x: B<string>): any; (x: C<string>): any; }
>x : C<string>
>C : C<T>
function foo9(x: any) { }
>foo9 : { (x: B<string>): any; (x: C<string>): any; }
>x : any
function foo10(x: B<string>);
>foo10 : { (x: B<string>): any; (x: new <T>(x: T, y?: T) => B<T>): any; }
>x : B<string>
>B : B<T>
function foo10(x: typeof a); // BUG 832086
>foo10 : { (x: B<string>): any; (x: new <T>(x: T, y?: T) => B<T>): any; }
>x : new <T>(x: T, y?: T) => B<T>
>a : new <T>(x: T, y?: T) => B<T>
function foo10(x: any) { }
>foo10 : { (x: B<string>): any; (x: new <T>(x: T, y?: T) => B<T>): any; }
>x : any
function foo11(x: B<string>);
>foo11 : { (x: B<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
>x : B<string>
>B : B<T>
function foo11(x: typeof b); // ok
>foo11 : { (x: B<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
>x : { new<T>(x: T, y?: T): C<T>; }
>b : { new<T>(x: T, y?: T): C<T>; }
function foo11(x: any) { }
>foo11 : { (x: B<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
>x : any
function foo12(x: I<string>);
>foo12 : { (x: I<string>): any; (x: C<string>): any; }
>x : I<string>
>I : I<T>
function foo12(x: C<string>); // ok
>foo12 : { (x: I<string>): any; (x: C<string>): any; }
>x : C<string>
>C : C<T>
function foo12(x: any) { }
>foo12 : { (x: I<string>): any; (x: C<string>): any; }
>x : any
function foo12b(x: I2);
>foo12b : { (x: I2): any; (x: C<string>): any; }
>x : I2
>I2 : I2
function foo12b(x: C<string>); // BUG 832086
>foo12b : { (x: I2): any; (x: C<string>): any; }
>x : C<string>
>C : C<T>
function foo12b(x: any) { }
>foo12b : { (x: I2): any; (x: C<string>): any; }
>x : any
function foo13(x: I<string>);
>foo13 : { (x: I<string>): any; (x: new <T>(x: T, y?: T) => B<T>): any; }
>x : I<string>
>I : I<T>
function foo13(x: typeof a); // BUG 832086
>foo13 : { (x: I<string>): any; (x: new <T>(x: T, y?: T) => B<T>): any; }
>x : new <T>(x: T, y?: T) => B<T>
>a : new <T>(x: T, y?: T) => B<T>
function foo13(x: any) { }
>foo13 : { (x: I<string>): any; (x: new <T>(x: T, y?: T) => B<T>): any; }
>x : any
function foo14(x: I<string>);
>foo14 : { (x: I<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
>x : I<string>
>I : I<T>
function foo14(x: typeof b); // ok
>foo14 : { (x: I<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
>x : { new<T>(x: T, y?: T): C<T>; }
>b : { new<T>(x: T, y?: T): C<T>; }
function foo14(x: any) { }
>foo14 : { (x: I<string>): any; (x: { new<T>(x: T, y?: T): C<T>; }): any; }
>x : any