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