2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.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 extends Array<number>> {
|
|
|
|
>B : B<T>
|
|
|
|
>T : T
|
2014-08-19 04:56:03 +02:00
|
|
|
>Array : T[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
constructor(x: T) { return null; }
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
|
|
|
|
class C<T extends String> {
|
|
|
|
>C : C<T>
|
|
|
|
>T : T
|
|
|
|
>String : String
|
|
|
|
|
|
|
|
constructor(x: T) { return null; }
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
|
|
|
|
interface I<T extends Number> {
|
|
|
|
>I : I<T>
|
|
|
|
>T : T
|
|
|
|
>Number : Number
|
|
|
|
|
|
|
|
new(x: T): string;
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
|
|
|
|
interface I2 {
|
|
|
|
>I2 : I2
|
|
|
|
|
|
|
|
new<T extends Boolean>(x: T): string;
|
|
|
|
>T : T
|
|
|
|
>Boolean : Boolean
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
|
|
|
|
var a: { new<T extends Array<string>>(x: T): string }
|
|
|
|
>a : new <T extends string[]>(x: T) => string
|
|
|
|
>T : T
|
2014-08-19 04:56:03 +02:00
|
|
|
>Array : T[]
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
var b = { new<T extends RegExp>(x: T) { return ''; } }; // not a construct signature, function called new
|
2014-12-03 12:05:37 +01:00
|
|
|
>b : { new<T extends RegExp>(x: T): string; }
|
|
|
|
>{ new<T extends RegExp>(x: T) { return ''; } } : { new<T extends RegExp>(x: T): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>new : <T extends RegExp>(x: T) => string
|
|
|
|
>T : T
|
|
|
|
>RegExp : RegExp
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
function foo1b(x: B<Array<number>>);
|
|
|
|
>foo1b : { (x: B<number[]>): any; (x: B<number[]>): any; }
|
|
|
|
>x : B<number[]>
|
2014-08-19 04:56:03 +02:00
|
|
|
>B : B<T>
|
|
|
|
>Array : T[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo1b(x: B<Array<number>>); // error
|
|
|
|
>foo1b : { (x: B<number[]>): any; (x: B<number[]>): any; }
|
|
|
|
>x : B<number[]>
|
2014-08-19 04:56:03 +02:00
|
|
|
>B : B<T>
|
|
|
|
>Array : T[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo1b(x: any) { }
|
|
|
|
>foo1b : { (x: B<number[]>): any; (x: B<number[]>): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo1c(x: C<String>);
|
|
|
|
>foo1c : { (x: C<String>): any; (x: C<String>): any; }
|
|
|
|
>x : C<String>
|
2014-08-19 04:56:03 +02:00
|
|
|
>C : C<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>String : String
|
|
|
|
|
|
|
|
function foo1c(x: C<String>); // error
|
|
|
|
>foo1c : { (x: C<String>): any; (x: C<String>): any; }
|
|
|
|
>x : C<String>
|
2014-08-19 04:56:03 +02:00
|
|
|
>C : C<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>String : String
|
|
|
|
|
|
|
|
function foo1c(x: any) { }
|
|
|
|
>foo1c : { (x: C<String>): any; (x: C<String>): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo2(x: I<Number>);
|
|
|
|
>foo2 : { (x: I<Number>): any; (x: I<Number>): any; }
|
|
|
|
>x : I<Number>
|
2014-08-19 04:56:03 +02:00
|
|
|
>I : I<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>Number : Number
|
|
|
|
|
|
|
|
function foo2(x: I<Number>); // error
|
|
|
|
>foo2 : { (x: I<Number>): any; (x: I<Number>): any; }
|
|
|
|
>x : I<Number>
|
2014-08-19 04:56:03 +02:00
|
|
|
>I : I<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>Number : Number
|
|
|
|
|
|
|
|
function foo2(x: any) { }
|
|
|
|
>foo2 : { (x: I<Number>): any; (x: I<Number>): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo3(x: typeof a);
|
|
|
|
>foo3 : { (x: new <T extends string[]>(x: T) => string): any; (x: new <T extends string[]>(x: T) => string): any; }
|
|
|
|
>x : new <T extends string[]>(x: T) => string
|
|
|
|
>a : new <T extends string[]>(x: T) => string
|
|
|
|
|
|
|
|
function foo3(x: typeof a); // error
|
|
|
|
>foo3 : { (x: new <T extends string[]>(x: T) => string): any; (x: new <T extends string[]>(x: T) => string): any; }
|
|
|
|
>x : new <T extends string[]>(x: T) => string
|
|
|
|
>a : new <T extends string[]>(x: T) => string
|
|
|
|
|
|
|
|
function foo3(x: any) { }
|
|
|
|
>foo3 : { (x: new <T extends string[]>(x: T) => string): any; (x: new <T extends string[]>(x: T) => string): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo4(x: typeof b);
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo4 : { (x: { new<T extends RegExp>(x: T): string; }): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
|
|
|
>x : { new<T extends RegExp>(x: T): string; }
|
|
|
|
>b : { new<T extends RegExp>(x: T): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo4(x: typeof b); // error
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo4 : { (x: { new<T extends RegExp>(x: T): string; }): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
|
|
|
>x : { new<T extends RegExp>(x: T): string; }
|
|
|
|
>b : { new<T extends RegExp>(x: T): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo4(x: any) { }
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo4 : { (x: { new<T extends RegExp>(x: T): string; }): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo8(x: B<Array<number>>);
|
|
|
|
>foo8 : { (x: B<number[]>): any; (x: I<Number>): any; }
|
|
|
|
>x : B<number[]>
|
2014-08-19 04:56:03 +02:00
|
|
|
>B : B<T>
|
|
|
|
>Array : T[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo8(x: I<Number>); // ok
|
|
|
|
>foo8 : { (x: B<number[]>): any; (x: I<Number>): any; }
|
|
|
|
>x : I<Number>
|
2014-08-19 04:56:03 +02:00
|
|
|
>I : I<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>Number : Number
|
|
|
|
|
|
|
|
function foo8(x: any) { }
|
|
|
|
>foo8 : { (x: B<number[]>): any; (x: I<Number>): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo9(x: B<Array<number>>);
|
|
|
|
>foo9 : { (x: B<number[]>): any; (x: C<String>): any; }
|
|
|
|
>x : B<number[]>
|
2014-08-19 04:56:03 +02:00
|
|
|
>B : B<T>
|
|
|
|
>Array : T[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo9(x: C<String>); // error, types are structurally equal
|
|
|
|
>foo9 : { (x: B<number[]>): any; (x: C<String>): any; }
|
|
|
|
>x : C<String>
|
2014-08-19 04:56:03 +02:00
|
|
|
>C : C<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>String : String
|
|
|
|
|
|
|
|
function foo9(x: any) { }
|
|
|
|
>foo9 : { (x: B<number[]>): any; (x: C<String>): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo10(x: B<Array<number>>);
|
|
|
|
>foo10 : { (x: B<number[]>): any; (x: new <T extends string[]>(x: T) => string): any; }
|
|
|
|
>x : B<number[]>
|
2014-08-19 04:56:03 +02:00
|
|
|
>B : B<T>
|
|
|
|
>Array : T[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo10(x: typeof a); // ok
|
|
|
|
>foo10 : { (x: B<number[]>): any; (x: new <T extends string[]>(x: T) => string): any; }
|
|
|
|
>x : new <T extends string[]>(x: T) => string
|
|
|
|
>a : new <T extends string[]>(x: T) => string
|
|
|
|
|
|
|
|
function foo10(x: any) { }
|
|
|
|
>foo10 : { (x: B<number[]>): any; (x: new <T extends string[]>(x: T) => string): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo11(x: B<Array<number>>);
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo11 : { (x: B<number[]>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : B<number[]>
|
2014-08-19 04:56:03 +02:00
|
|
|
>B : B<T>
|
|
|
|
>Array : T[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo11(x: typeof b); // ok
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo11 : { (x: B<number[]>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
|
|
|
>x : { new<T extends RegExp>(x: T): string; }
|
|
|
|
>b : { new<T extends RegExp>(x: T): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo11(x: any) { }
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo11 : { (x: B<number[]>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo12(x: I<Number>);
|
|
|
|
>foo12 : { (x: I<Number>): any; (x: C<String>): any; }
|
|
|
|
>x : I<Number>
|
2014-08-19 04:56:03 +02:00
|
|
|
>I : I<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>Number : Number
|
|
|
|
|
|
|
|
function foo12(x: C<String>); // ok
|
|
|
|
>foo12 : { (x: I<Number>): any; (x: C<String>): any; }
|
|
|
|
>x : C<String>
|
2014-08-19 04:56:03 +02:00
|
|
|
>C : C<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>String : String
|
|
|
|
|
|
|
|
function foo12(x: any) { }
|
|
|
|
>foo12 : { (x: I<Number>): 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>); // ok
|
|
|
|
>foo12b : { (x: I2): any; (x: C<String>): any; }
|
|
|
|
>x : C<String>
|
2014-08-19 04:56:03 +02:00
|
|
|
>C : C<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>String : String
|
|
|
|
|
|
|
|
function foo12b(x: any) { }
|
|
|
|
>foo12b : { (x: I2): any; (x: C<String>): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo13(x: I<Number>);
|
|
|
|
>foo13 : { (x: I<Number>): any; (x: new <T extends string[]>(x: T) => string): any; }
|
|
|
|
>x : I<Number>
|
2014-08-19 04:56:03 +02:00
|
|
|
>I : I<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>Number : Number
|
|
|
|
|
|
|
|
function foo13(x: typeof a); // ok
|
|
|
|
>foo13 : { (x: I<Number>): any; (x: new <T extends string[]>(x: T) => string): any; }
|
|
|
|
>x : new <T extends string[]>(x: T) => string
|
|
|
|
>a : new <T extends string[]>(x: T) => string
|
|
|
|
|
|
|
|
function foo13(x: any) { }
|
|
|
|
>foo13 : { (x: I<Number>): any; (x: new <T extends string[]>(x: T) => string): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo14(x: I<Number>);
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo14 : { (x: I<Number>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : I<Number>
|
2014-08-19 04:56:03 +02:00
|
|
|
>I : I<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>Number : Number
|
|
|
|
|
|
|
|
function foo14(x: typeof b); // ok
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo14 : { (x: I<Number>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
|
|
|
>x : { new<T extends RegExp>(x: T): string; }
|
|
|
|
>b : { new<T extends RegExp>(x: T): string; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo14(x: any) { }
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo14 : { (x: I<Number>): any; (x: { new<T extends RegExp>(x: T): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|