398 lines
8 KiB
Text
398 lines
8 KiB
Text
=== tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithNumericIndexers2.ts ===
|
|
// object types are identical structurally
|
|
|
|
class Base { foo: string; }
|
|
>Base : Base
|
|
>foo : string
|
|
|
|
class Derived extends Base { bar: string; }
|
|
>Derived : Derived
|
|
>Base : Base
|
|
>bar : string
|
|
|
|
class A {
|
|
>A : A
|
|
|
|
[x: number]: Base;
|
|
>x : number
|
|
>Base : Base
|
|
}
|
|
|
|
class B {
|
|
>B : B
|
|
|
|
[x: number]: Derived;
|
|
>x : number
|
|
>Derived : Derived
|
|
}
|
|
|
|
class C<T> {
|
|
>C : C<T>
|
|
>T : T
|
|
|
|
[x: number]: T;
|
|
>x : number
|
|
>T : T
|
|
}
|
|
|
|
interface I {
|
|
>I : I
|
|
|
|
[x: number]: Derived;
|
|
>x : number
|
|
>Derived : Derived
|
|
}
|
|
|
|
class PA extends A {
|
|
>PA : PA
|
|
>A : A
|
|
}
|
|
|
|
class PB extends B {
|
|
>PB : PB
|
|
>B : B
|
|
}
|
|
|
|
var a: {
|
|
>a : { [x: number]: Base; }
|
|
|
|
[x: number]: Base;
|
|
>x : number
|
|
>Base : Base
|
|
}
|
|
var b: { [x: number]: Derived; } = { foo: <Derived>null };
|
|
>b : { [x: number]: Derived; }
|
|
>x : number
|
|
>Derived : Derived
|
|
>{ foo: <Derived>null } : { [x: number]: undefined; foo: Derived; }
|
|
>foo : Derived
|
|
><Derived>null : Derived
|
|
>Derived : Derived
|
|
>null : null
|
|
|
|
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);
|
|
>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>
|
|
>C : C<T>
|
|
|
|
function foo1c(x: C<string>); // error
|
|
>foo1c : { (x: C<string>): any; (x: C<string>): any; }
|
|
>x : C<string>
|
|
>C : C<T>
|
|
|
|
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: { [x: number]: Base; }): any; (x: { [x: number]: Base; }): any; }
|
|
>x : { [x: number]: Base; }
|
|
>a : { [x: number]: Base; }
|
|
|
|
function foo3(x: typeof a); // error
|
|
>foo3 : { (x: { [x: number]: Base; }): any; (x: { [x: number]: Base; }): any; }
|
|
>x : { [x: number]: Base; }
|
|
>a : { [x: number]: Base; }
|
|
|
|
function foo3(x: any) { }
|
|
>foo3 : { (x: { [x: number]: Base; }): any; (x: { [x: number]: Base; }): any; }
|
|
>x : any
|
|
|
|
function foo4(x: typeof b);
|
|
>foo4 : { (x: { [x: number]: Derived; }): any; (x: { [x: number]: Derived; }): any; }
|
|
>x : { [x: number]: Derived; }
|
|
>b : { [x: number]: Derived; }
|
|
|
|
function foo4(x: typeof b); // error
|
|
>foo4 : { (x: { [x: number]: Derived; }): any; (x: { [x: number]: Derived; }): any; }
|
|
>x : { [x: number]: Derived; }
|
|
>b : { [x: number]: Derived; }
|
|
|
|
function foo4(x: any) { }
|
|
>foo4 : { (x: { [x: number]: Derived; }): any; (x: { [x: number]: Derived; }): any; }
|
|
>x : any
|
|
|
|
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<Derived>): any; }
|
|
>x : A
|
|
>A : A
|
|
|
|
function foo5b(x: C<Derived>); // ok
|
|
>foo5b : { (x: A): any; (x: C<Derived>): any; }
|
|
>x : C<Derived>
|
|
>C : C<T>
|
|
>Derived : Derived
|
|
|
|
function foo5b(x: any) { }
|
|
>foo5b : { (x: A): any; (x: C<Derived>): any; }
|
|
>x : any
|
|
|
|
function foo5c(x: A);
|
|
>foo5c : { (x: A): any; (x: PA): any; }
|
|
>x : A
|
|
>A : A
|
|
|
|
function foo5c(x: PA); // error
|
|
>foo5c : { (x: A): any; (x: PA): any; }
|
|
>x : PA
|
|
>PA : PA
|
|
|
|
function foo5c(x: any) { }
|
|
>foo5c : { (x: A): any; (x: PA): any; }
|
|
>x : any
|
|
|
|
function foo5d(x: A);
|
|
>foo5d : { (x: A): any; (x: PB): any; }
|
|
>x : A
|
|
>A : A
|
|
|
|
function foo5d(x: PB); // ok
|
|
>foo5d : { (x: A): any; (x: PB): any; }
|
|
>x : PB
|
|
>PB : PB
|
|
|
|
function foo5d(x: any) { }
|
|
>foo5d : { (x: A): any; (x: PB): 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: { [x: number]: Base; }): any; }
|
|
>x : A
|
|
>A : A
|
|
|
|
function foo7(x: typeof a); // error
|
|
>foo7 : { (x: A): any; (x: { [x: number]: Base; }): any; }
|
|
>x : { [x: number]: Base; }
|
|
>a : { [x: number]: Base; }
|
|
|
|
function foo7(x: any) { }
|
|
>foo7 : { (x: A): any; (x: { [x: number]: Base; }): any; }
|
|
>x : any
|
|
|
|
function foo8(x: B);
|
|
>foo8 : { (x: B): any; (x: I): any; }
|
|
>x : B
|
|
>B : B
|
|
|
|
function foo8(x: I); // error
|
|
>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<Base>): any; }
|
|
>x : B
|
|
>B : B
|
|
|
|
function foo9(x: C<Base>); // ok
|
|
>foo9 : { (x: B): any; (x: C<Base>): any; }
|
|
>x : C<Base>
|
|
>C : C<T>
|
|
>Base : Base
|
|
|
|
function foo9(x: any) { }
|
|
>foo9 : { (x: B): any; (x: C<Base>): any; }
|
|
>x : any
|
|
|
|
function foo10(x: B);
|
|
>foo10 : { (x: B): any; (x: { [x: number]: Base; }): any; }
|
|
>x : B
|
|
>B : B
|
|
|
|
function foo10(x: typeof a); // ok
|
|
>foo10 : { (x: B): any; (x: { [x: number]: Base; }): any; }
|
|
>x : { [x: number]: Base; }
|
|
>a : { [x: number]: Base; }
|
|
|
|
function foo10(x: any) { }
|
|
>foo10 : { (x: B): any; (x: { [x: number]: Base; }): any; }
|
|
>x : any
|
|
|
|
function foo11(x: B);
|
|
>foo11 : { (x: B): any; (x: { [x: number]: Derived; }): any; }
|
|
>x : B
|
|
>B : B
|
|
|
|
function foo11(x: typeof b); // error
|
|
>foo11 : { (x: B): any; (x: { [x: number]: Derived; }): any; }
|
|
>x : { [x: number]: Derived; }
|
|
>b : { [x: number]: Derived; }
|
|
|
|
function foo11(x: any) { }
|
|
>foo11 : { (x: B): any; (x: { [x: number]: Derived; }): any; }
|
|
>x : any
|
|
|
|
function foo11b(x: B);
|
|
>foo11b : { (x: B): any; (x: PA): any; }
|
|
>x : B
|
|
>B : B
|
|
|
|
function foo11b(x: PA); // ok
|
|
>foo11b : { (x: B): any; (x: PA): any; }
|
|
>x : PA
|
|
>PA : PA
|
|
|
|
function foo11b(x: any) { }
|
|
>foo11b : { (x: B): any; (x: PA): any; }
|
|
>x : any
|
|
|
|
function foo11c(x: B);
|
|
>foo11c : { (x: B): any; (x: PB): any; }
|
|
>x : B
|
|
>B : B
|
|
|
|
function foo11c(x: PB); // error
|
|
>foo11c : { (x: B): any; (x: PB): any; }
|
|
>x : PB
|
|
>PB : PB
|
|
|
|
function foo11c(x: any) { }
|
|
>foo11c : { (x: B): any; (x: PB): any; }
|
|
>x : any
|
|
|
|
function foo12(x: I);
|
|
>foo12 : { (x: I): any; (x: C<Derived>): any; }
|
|
>x : I
|
|
>I : I
|
|
|
|
function foo12(x: C<Derived>); // error
|
|
>foo12 : { (x: I): any; (x: C<Derived>): any; }
|
|
>x : C<Derived>
|
|
>C : C<T>
|
|
>Derived : Derived
|
|
|
|
function foo12(x: any) { }
|
|
>foo12 : { (x: I): any; (x: C<Derived>): any; }
|
|
>x : any
|
|
|
|
function foo13(x: I);
|
|
>foo13 : { (x: I): any; (x: { [x: number]: Base; }): any; }
|
|
>x : I
|
|
>I : I
|
|
|
|
function foo13(x: typeof a); // ok
|
|
>foo13 : { (x: I): any; (x: { [x: number]: Base; }): any; }
|
|
>x : { [x: number]: Base; }
|
|
>a : { [x: number]: Base; }
|
|
|
|
function foo13(x: any) { }
|
|
>foo13 : { (x: I): any; (x: { [x: number]: Base; }): any; }
|
|
>x : any
|
|
|
|
function foo14(x: I);
|
|
>foo14 : { (x: I): any; (x: { [x: number]: Derived; }): any; }
|
|
>x : I
|
|
>I : I
|
|
|
|
function foo14(x: typeof b); // error
|
|
>foo14 : { (x: I): any; (x: { [x: number]: Derived; }): any; }
|
|
>x : { [x: number]: Derived; }
|
|
>b : { [x: number]: Derived; }
|
|
|
|
function foo14(x: any) { }
|
|
>foo14 : { (x: I): any; (x: { [x: number]: Derived; }): any; }
|
|
>x : any
|
|
|
|
function foo15(x: I);
|
|
>foo15 : { (x: I): any; (x: PA): any; }
|
|
>x : I
|
|
>I : I
|
|
|
|
function foo15(x: PA); // ok
|
|
>foo15 : { (x: I): any; (x: PA): any; }
|
|
>x : PA
|
|
>PA : PA
|
|
|
|
function foo15(x: any) { }
|
|
>foo15 : { (x: I): any; (x: PA): any; }
|
|
>x : any
|
|
|
|
function foo16(x: I);
|
|
>foo16 : { (x: I): any; (x: PB): any; }
|
|
>x : I
|
|
>I : I
|
|
|
|
function foo16(x: PB); // error
|
|
>foo16 : { (x: I): any; (x: PB): any; }
|
|
>x : PB
|
|
>PB : PB
|
|
|
|
function foo16(x: any) { }
|
|
>foo16 : { (x: I): any; (x: PB): any; }
|
|
>x : any
|
|
|
|
|