2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentity2.ts ===
|
|
|
|
// object types are identical structurally
|
|
|
|
|
|
|
|
class A {
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
foo: number;
|
|
|
|
>foo : number
|
|
|
|
}
|
|
|
|
|
|
|
|
class B {
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
foo: boolean;
|
|
|
|
>foo : boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
class C<T> {
|
|
|
|
>C : C<T>
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
foo: T;
|
|
|
|
>foo : T
|
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
|
|
|
|
interface I {
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
foo: Date;
|
|
|
|
>foo : Date
|
|
|
|
>Date : Date
|
|
|
|
}
|
|
|
|
|
|
|
|
var a: { foo: RegExp; }
|
|
|
|
>a : { foo: RegExp; }
|
|
|
|
>foo : RegExp
|
|
|
|
>RegExp : RegExp
|
|
|
|
|
|
|
|
enum E { A }
|
|
|
|
>E : E
|
|
|
|
>A : E
|
|
|
|
|
|
|
|
var b = { foo: E.A };
|
|
|
|
>b : { foo: E; }
|
|
|
|
>{ foo: E.A } : { foo: E; }
|
|
|
|
>foo : E
|
|
|
|
>E.A : E
|
|
|
|
>E : typeof E
|
|
|
|
>A : E
|
|
|
|
|
|
|
|
function foo5(x: A);
|
|
|
|
>foo5 : { (x: A): any; (x: B): any; }
|
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo5(x: B); // ok
|
|
|
|
>foo5 : { (x: A): any; (x: B): any; }
|
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
function foo5(x: any) { }
|
|
|
|
>foo5 : { (x: A): any; (x: B): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo5b(x: A);
|
|
|
|
>foo5b : { (x: A): any; (x: C<string>): any; }
|
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo5b(x: C<string>); // ok
|
|
|
|
>foo5b : { (x: A): 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 foo5b(x: any) { }
|
|
|
|
>foo5b : { (x: A): any; (x: C<string>): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo6(x: A);
|
|
|
|
>foo6 : { (x: A): any; (x: I): any; }
|
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo6(x: I); // ok
|
|
|
|
>foo6 : { (x: A): any; (x: I): any; }
|
|
|
|
>x : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
function foo6(x: any) { }
|
|
|
|
>foo6 : { (x: A): any; (x: I): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo7(x: A);
|
|
|
|
>foo7 : { (x: A): any; (x: { foo: RegExp; }): any; }
|
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo7(x: typeof a); // ok
|
|
|
|
>foo7 : { (x: A): any; (x: { foo: RegExp; }): any; }
|
|
|
|
>x : { foo: RegExp; }
|
|
|
|
>a : { foo: RegExp; }
|
|
|
|
|
|
|
|
function foo7(x: any) { }
|
|
|
|
>foo7 : { (x: A): any; (x: { foo: RegExp; }): any; }
|
|
|
|
>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>); // ok
|
|
|
|
>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: { foo: RegExp; }): any; }
|
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
function foo10(x: typeof a); // ok
|
|
|
|
>foo10 : { (x: B): any; (x: { foo: RegExp; }): any; }
|
|
|
|
>x : { foo: RegExp; }
|
|
|
|
>a : { foo: RegExp; }
|
|
|
|
|
|
|
|
function foo10(x: any) { }
|
|
|
|
>foo10 : { (x: B): any; (x: { foo: RegExp; }): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo11(x: B);
|
|
|
|
>foo11 : { (x: B): any; (x: { foo: E; }): any; }
|
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
function foo11(x: typeof b); // ok
|
|
|
|
>foo11 : { (x: B): any; (x: { foo: E; }): any; }
|
|
|
|
>x : { foo: E; }
|
|
|
|
>b : { foo: E; }
|
|
|
|
|
|
|
|
function foo11(x: any) { }
|
|
|
|
>foo11 : { (x: B): any; (x: { foo: E; }): any; }
|
|
|
|
>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 foo13(x: I);
|
|
|
|
>foo13 : { (x: I): any; (x: { foo: RegExp; }): any; }
|
|
|
|
>x : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
function foo13(x: typeof a); // ok
|
|
|
|
>foo13 : { (x: I): any; (x: { foo: RegExp; }): any; }
|
|
|
|
>x : { foo: RegExp; }
|
|
|
|
>a : { foo: RegExp; }
|
|
|
|
|
|
|
|
function foo13(x: any) { }
|
|
|
|
>foo13 : { (x: I): any; (x: { foo: RegExp; }): any; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo14(x: I);
|
|
|
|
>foo14 : { (x: I): any; (x: { foo: E; }): any; }
|
|
|
|
>x : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
function foo14(x: typeof b); // ok
|
|
|
|
>foo14 : { (x: I): any; (x: { foo: E; }): any; }
|
|
|
|
>x : { foo: E; }
|
|
|
|
>b : { foo: E; }
|
|
|
|
|
|
|
|
function foo14(x: any) { }
|
|
|
|
>foo14 : { (x: I): any; (x: { foo: E; }): any; }
|
|
|
|
>x : any
|
|
|
|
|