2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithCallSignaturesWithOverloads.ts ===
|
|
|
|
// object types are identical structurally
|
|
|
|
|
|
|
|
class A {
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
foo(x: number): number;
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
foo(x: string): string;
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
foo(x: any): any { return null; }
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : any
|
|
|
|
}
|
|
|
|
|
|
|
|
class B {
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
foo(x: number): number;
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
foo(x: string): string;
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
foo(x: any): any { return null; }
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : any
|
|
|
|
}
|
|
|
|
|
|
|
|
class C<T> {
|
|
|
|
>C : C<T>
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
foo(x: number): number;
|
|
|
|
>foo : { (x: number): number; (x: string): string; (x: T): T; }
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
foo(x: string): string;
|
|
|
|
>foo : { (x: number): number; (x: string): string; (x: T): T; }
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
foo(x: T): T;
|
|
|
|
>foo : { (x: number): number; (x: string): string; (x: T): T; }
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
foo(x: any): any { return null; }
|
|
|
|
>foo : { (x: number): number; (x: string): string; (x: T): T; }
|
|
|
|
>x : any
|
|
|
|
}
|
|
|
|
|
|
|
|
interface I {
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
foo(x: number): number;
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
foo(x: string): string;
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : string
|
|
|
|
}
|
|
|
|
|
|
|
|
interface I2<T> {
|
|
|
|
>I2 : I2<T>
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
foo(x: number): number;
|
|
|
|
>foo : { (x: number): number; (x: string): string; (x: T): T; }
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
foo(x: string): string;
|
|
|
|
>foo : { (x: number): number; (x: string): string; (x: T): T; }
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
foo(x: T): T;
|
|
|
|
>foo : { (x: number): number; (x: string): string; (x: T): T; }
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
|
|
|
|
var a: {
|
|
|
|
>a : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
|
|
|
|
foo(x: number): number
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
foo(x: string): string
|
|
|
|
>foo : { (x: number): number; (x: string): string; }
|
|
|
|
>x : string
|
|
|
|
}
|
|
|
|
|
|
|
|
var b = {
|
2014-12-03 12:05:37 +01:00
|
|
|
>b : { foo(x: any): any; }
|
|
|
|
>{ foo(x: any) { return <any>''; }} : { foo(x: any): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
foo(x: any) { return <any>''; }
|
|
|
|
>foo : (x: any) => any
|
|
|
|
>x : any
|
|
|
|
><any>'' : any
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
function foo1(x: A);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo1 : { (x: A): any; (x: A): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo1(x: A); // error
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo1 : { (x: A): any; (x: A): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo1(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo1 : { (x: A): any; (x: A): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo1b(x: B);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo1b : { (x: B): any; (x: B): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
function foo1b(x: B); // error
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo1b : { (x: B): any; (x: B): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
function foo1b(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo1b : { (x: B): any; (x: B): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo1c(x: C<string>);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo1c : { (x: C<string>): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>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
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo1c : { (x: C<string>): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>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) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo1c : { (x: C<string>): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo2(x: I);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo2 : { (x: I): any; (x: I): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
function foo2(x: I); // error
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo2 : { (x: I): any; (x: I): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
function foo2(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo2 : { (x: I): any; (x: I): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo3(x: typeof a);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo3 : { (x: { foo(x: number): number; foo(x: string): string; }): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
>a : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
|
|
|
|
function foo3(x: typeof a); // error
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo3 : { (x: { foo(x: number): number; foo(x: string): string; }): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
>a : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
|
|
|
|
function foo3(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo3 : { (x: { foo(x: number): number; foo(x: string): string; }): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo4(x: typeof b);
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo4 : { (x: { foo(x: any): any; }): any; (x: { foo(x: any): any; }): any; }
|
|
|
|
>x : { foo(x: any): any; }
|
|
|
|
>b : { foo(x: any): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo4(x: typeof b); // error
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo4 : { (x: { foo(x: any): any; }): any; (x: { foo(x: any): any; }): any; }
|
|
|
|
>x : { foo(x: any): any; }
|
|
|
|
>b : { foo(x: any): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo4(x: any) { }
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo4 : { (x: { foo(x: any): any; }): any; (x: { foo(x: any): any; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo5(x: A);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo5 : { (x: A): any; (x: B): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo5(x: B); // error
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo5 : { (x: A): any; (x: B): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
function foo5(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo5 : { (x: A): any; (x: B): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo5b(x: A);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo5b : { (x: A): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo5b(x: C<string>); // ok
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo5b : { (x: A): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>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) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo5b : { (x: A): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo6(x: A);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo6 : { (x: A): any; (x: I): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo6(x: I); // BUG 831930
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo6 : { (x: A): any; (x: I): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
function foo6(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo6 : { (x: A): any; (x: I): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo7(x: A);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo7 : { (x: A): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
function foo7(x: typeof a); // BUG 831930
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo7 : { (x: A): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
>a : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
|
|
|
|
function foo7(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo7 : { (x: A): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo8(x: B);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo8 : { (x: B): any; (x: I): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
function foo8(x: I); // BUG 831930
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo8 : { (x: B): any; (x: I): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
function foo8(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo8 : { (x: B): any; (x: I): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo9(x: B);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo9 : { (x: B): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
function foo9(x: C<string>); // ok
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo9 : { (x: B): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>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) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo9 : { (x: B): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo10(x: B);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo10 : { (x: B): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : B
|
|
|
|
>B : B
|
|
|
|
|
|
|
|
function foo10(x: typeof a); // BUG 831930
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo10 : { (x: B): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
>a : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
|
|
|
|
function foo10(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo10 : { (x: B): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo11(x: B);
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo11 : { (x: B): any; (x: { foo(x: any): any; }): 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: { foo(x: any): any; }): any; }
|
|
|
|
>x : { foo(x: any): any; }
|
|
|
|
>b : { foo(x: any): any; }
|
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: { foo(x: any): any; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo12(x: I);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo12 : { (x: I): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
function foo12(x: C<string>); // ok
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo12 : { (x: I): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>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) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo12 : { (x: I): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo12b(x: I2<string>);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo12b : { (x: I2<string>): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>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
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo12b : { (x: I2<string>): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>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) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo12b : { (x: I2<string>): any; (x: C<string>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo13(x: I);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo13 : { (x: I): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
function foo13(x: typeof a); // error
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo13 : { (x: I): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
>a : { foo(x: number): number; foo(x: string): string; }
|
|
|
|
|
|
|
|
function foo13(x: any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo13 : { (x: I): any; (x: { foo(x: number): number; foo(x: string): string; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo14(x: I);
|
2014-12-03 12:05:37 +01:00
|
|
|
>foo14 : { (x: I): any; (x: { foo(x: any): any; }): 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: { foo(x: any): any; }): any; }
|
|
|
|
>x : { foo(x: any): any; }
|
|
|
|
>b : { foo(x: any): any; }
|
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: { foo(x: any): any; }): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
function foo15(x: I2<string>);
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo15 : { (x: I2<string>): any; (x: C<number>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>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
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo15 : { (x: I2<string>): any; (x: C<number>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>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) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>foo15 : { (x: I2<string>): any; (x: C<number>): any; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|