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