565 lines
15 KiB
Text
565 lines
15 KiB
Text
=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts ===
|
|
// checking assignment compatibility relations for function types. All of these are valid.
|
|
|
|
class Base { foo: string; }
|
|
>Base : Base
|
|
>foo : string
|
|
|
|
class Derived extends Base { bar: string; }
|
|
>Derived : Derived
|
|
>Base : Base
|
|
>bar : string
|
|
|
|
class Derived2 extends Derived { baz: string; }
|
|
>Derived2 : Derived2
|
|
>Derived : Derived
|
|
>baz : string
|
|
|
|
class OtherDerived extends Base { bing: string; }
|
|
>OtherDerived : OtherDerived
|
|
>Base : Base
|
|
>bing : string
|
|
|
|
var a: new (x: number) => number[];
|
|
>a : new (x: number) => number[]
|
|
>x : number
|
|
|
|
var a2: new (x: number) => string[];
|
|
>a2 : new (x: number) => string[]
|
|
>x : number
|
|
|
|
var a3: new (x: number) => void;
|
|
>a3 : new (x: number) => void
|
|
>x : number
|
|
|
|
var a4: new (x: string, y: number) => string;
|
|
>a4 : new (x: string, y: number) => string
|
|
>x : string
|
|
>y : number
|
|
|
|
var a5: new (x: (arg: string) => number) => string;
|
|
>a5 : new (x: (arg: string) => number) => string
|
|
>x : (arg: string) => number
|
|
>arg : string
|
|
|
|
var a6: new (x: (arg: Base) => Derived) => Base;
|
|
>a6 : new (x: (arg: Base) => Derived) => Base
|
|
>x : (arg: Base) => Derived
|
|
>arg : Base
|
|
>Base : Base
|
|
>Derived : Derived
|
|
>Base : Base
|
|
|
|
var a7: new (x: (arg: Base) => Derived) => (r: Base) => Derived;
|
|
>a7 : new (x: (arg: Base) => Derived) => (r: Base) => Derived
|
|
>x : (arg: Base) => Derived
|
|
>arg : Base
|
|
>Base : Base
|
|
>Derived : Derived
|
|
>r : Base
|
|
>Base : Base
|
|
>Derived : Derived
|
|
|
|
var a8: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
|
|
>a8 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
|
|
>x : (arg: Base) => Derived
|
|
>arg : Base
|
|
>Base : Base
|
|
>Derived : Derived
|
|
>y : (arg2: Base) => Derived
|
|
>arg2 : Base
|
|
>Base : Base
|
|
>Derived : Derived
|
|
>r : Base
|
|
>Base : Base
|
|
>Derived : Derived
|
|
|
|
var a9: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
|
|
>a9 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
|
|
>x : (arg: Base) => Derived
|
|
>arg : Base
|
|
>Base : Base
|
|
>Derived : Derived
|
|
>y : (arg2: Base) => Derived
|
|
>arg2 : Base
|
|
>Base : Base
|
|
>Derived : Derived
|
|
>r : Base
|
|
>Base : Base
|
|
>Derived : Derived
|
|
|
|
var a10: new (...x: Derived[]) => Derived;
|
|
>a10 : new (...x: Derived[]) => Derived
|
|
>x : Derived[]
|
|
>Derived : Derived
|
|
>Derived : Derived
|
|
|
|
var a11: new (x: { foo: string }, y: { foo: string; bar: string }) => Base;
|
|
>a11 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base
|
|
>x : { foo: string; }
|
|
>foo : string
|
|
>y : { foo: string; bar: string; }
|
|
>foo : string
|
|
>bar : string
|
|
>Base : Base
|
|
|
|
var a12: new (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
|
|
>a12 : new (x: Base[], y: Derived2[]) => Derived[]
|
|
>x : Base[]
|
|
>Array : T[]
|
|
>Base : Base
|
|
>y : Derived2[]
|
|
>Array : T[]
|
|
>Derived2 : Derived2
|
|
>Array : T[]
|
|
>Derived : Derived
|
|
|
|
var a13: new (x: Array<Base>, y: Array<Derived>) => Array<Derived>;
|
|
>a13 : new (x: Base[], y: Derived[]) => Derived[]
|
|
>x : Base[]
|
|
>Array : T[]
|
|
>Base : Base
|
|
>y : Derived[]
|
|
>Array : T[]
|
|
>Derived : Derived
|
|
>Array : T[]
|
|
>Derived : Derived
|
|
|
|
var a14: new (x: { a: string; b: number }) => Object;
|
|
>a14 : new (x: { a: string; b: number; }) => Object
|
|
>x : { a: string; b: number; }
|
|
>a : string
|
|
>b : number
|
|
>Object : Object
|
|
|
|
var a15: {
|
|
>a15 : { new (x: number): number[]; new (x: string): string[]; }
|
|
|
|
new (x: number): number[];
|
|
>x : number
|
|
|
|
new (x: string): string[];
|
|
>x : string
|
|
}
|
|
var a16: {
|
|
>a16 : { new <T extends Derived>(x: T): number[]; new <U extends Base>(x: U): number[]; }
|
|
|
|
new <T extends Derived>(x: T): number[];
|
|
>T : T
|
|
>Derived : Derived
|
|
>x : T
|
|
>T : T
|
|
|
|
new <U extends Base>(x: U): number[];
|
|
>U : U
|
|
>Base : Base
|
|
>x : U
|
|
>U : U
|
|
}
|
|
var a17: {
|
|
>a17 : { new (x: new (a: number) => number): number[]; new (x: new (a: string) => string): string[]; }
|
|
|
|
new (x: new (a: number) => number): number[];
|
|
>x : new (a: number) => number
|
|
>a : number
|
|
|
|
new (x: new (a: string) => string): string[];
|
|
>x : new (a: string) => string
|
|
>a : string
|
|
|
|
};
|
|
var a18: {
|
|
>a18 : { new (x: { new (a: number): number; new (a: string): string; }): any[]; new (x: { new (a: boolean): boolean; new (a: Date): Date; }): any[]; }
|
|
|
|
new (x: {
|
|
>x : { new (a: number): number; new (a: string): string; }
|
|
|
|
new (a: number): number;
|
|
>a : number
|
|
|
|
new (a: string): string;
|
|
>a : string
|
|
|
|
}): any[];
|
|
new (x: {
|
|
>x : { new (a: boolean): boolean; new (a: Date): Date; }
|
|
|
|
new (a: boolean): boolean;
|
|
>a : boolean
|
|
|
|
new (a: Date): Date;
|
|
>a : Date
|
|
>Date : Date
|
|
>Date : Date
|
|
|
|
}): any[];
|
|
}
|
|
|
|
var b: new <T>(x: T) => T[];
|
|
>b : new <T>(x: T) => T[]
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a = b; // ok
|
|
>a = b : new <T>(x: T) => T[]
|
|
>a : new (x: number) => number[]
|
|
>b : new <T>(x: T) => T[]
|
|
|
|
b = a; // ok
|
|
>b = a : new (x: number) => number[]
|
|
>b : new <T>(x: T) => T[]
|
|
>a : new (x: number) => number[]
|
|
|
|
var b2: new <T>(x: T) => string[];
|
|
>b2 : new <T>(x: T) => string[]
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
a2 = b2; // ok
|
|
>a2 = b2 : new <T>(x: T) => string[]
|
|
>a2 : new (x: number) => string[]
|
|
>b2 : new <T>(x: T) => string[]
|
|
|
|
b2 = a2; // ok
|
|
>b2 = a2 : new (x: number) => string[]
|
|
>b2 : new <T>(x: T) => string[]
|
|
>a2 : new (x: number) => string[]
|
|
|
|
var b3: new <T>(x: T) => T;
|
|
>b3 : new <T>(x: T) => T
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a3 = b3; // ok
|
|
>a3 = b3 : new <T>(x: T) => T
|
|
>a3 : new (x: number) => void
|
|
>b3 : new <T>(x: T) => T
|
|
|
|
b3 = a3; // ok
|
|
>b3 = a3 : new (x: number) => void
|
|
>b3 : new <T>(x: T) => T
|
|
>a3 : new (x: number) => void
|
|
|
|
var b4: new <T, U>(x: T, y: U) => T;
|
|
>b4 : new <T, U>(x: T, y: U) => T
|
|
>T : T
|
|
>U : U
|
|
>x : T
|
|
>T : T
|
|
>y : U
|
|
>U : U
|
|
>T : T
|
|
|
|
a4 = b4; // ok
|
|
>a4 = b4 : new <T, U>(x: T, y: U) => T
|
|
>a4 : new (x: string, y: number) => string
|
|
>b4 : new <T, U>(x: T, y: U) => T
|
|
|
|
b4 = a4; // ok
|
|
>b4 = a4 : new (x: string, y: number) => string
|
|
>b4 : new <T, U>(x: T, y: U) => T
|
|
>a4 : new (x: string, y: number) => string
|
|
|
|
var b5: new <T, U>(x: (arg: T) => U) => T;
|
|
>b5 : new <T, U>(x: (arg: T) => U) => T
|
|
>T : T
|
|
>U : U
|
|
>x : (arg: T) => U
|
|
>arg : T
|
|
>T : T
|
|
>U : U
|
|
>T : T
|
|
|
|
a5 = b5; // ok
|
|
>a5 = b5 : new <T, U>(x: (arg: T) => U) => T
|
|
>a5 : new (x: (arg: string) => number) => string
|
|
>b5 : new <T, U>(x: (arg: T) => U) => T
|
|
|
|
b5 = a5; // ok
|
|
>b5 = a5 : new (x: (arg: string) => number) => string
|
|
>b5 : new <T, U>(x: (arg: T) => U) => T
|
|
>a5 : new (x: (arg: string) => number) => string
|
|
|
|
var b6: new <T extends Base, U extends Derived>(x: (arg: T) => U) => T;
|
|
>b6 : new <T extends Base, U extends Derived>(x: (arg: T) => U) => T
|
|
>T : T
|
|
>Base : Base
|
|
>U : U
|
|
>Derived : Derived
|
|
>x : (arg: T) => U
|
|
>arg : T
|
|
>T : T
|
|
>U : U
|
|
>T : T
|
|
|
|
a6 = b6; // ok
|
|
>a6 = b6 : new <T extends Base, U extends Derived>(x: (arg: T) => U) => T
|
|
>a6 : new (x: (arg: Base) => Derived) => Base
|
|
>b6 : new <T extends Base, U extends Derived>(x: (arg: T) => U) => T
|
|
|
|
b6 = a6; // ok
|
|
>b6 = a6 : new (x: (arg: Base) => Derived) => Base
|
|
>b6 : new <T extends Base, U extends Derived>(x: (arg: T) => U) => T
|
|
>a6 : new (x: (arg: Base) => Derived) => Base
|
|
|
|
var b7: new <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U;
|
|
>b7 : new <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U
|
|
>T : T
|
|
>Base : Base
|
|
>U : U
|
|
>Derived : Derived
|
|
>x : (arg: T) => U
|
|
>arg : T
|
|
>T : T
|
|
>U : U
|
|
>r : T
|
|
>T : T
|
|
>U : U
|
|
|
|
a7 = b7; // ok
|
|
>a7 = b7 : new <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U
|
|
>a7 : new (x: (arg: Base) => Derived) => (r: Base) => Derived
|
|
>b7 : new <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U
|
|
|
|
b7 = a7; // ok
|
|
>b7 = a7 : new (x: (arg: Base) => Derived) => (r: Base) => Derived
|
|
>b7 : new <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U
|
|
>a7 : new (x: (arg: Base) => Derived) => (r: Base) => Derived
|
|
|
|
var b8: new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U;
|
|
>b8 : new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U
|
|
>T : T
|
|
>Base : Base
|
|
>U : U
|
|
>Derived : Derived
|
|
>x : (arg: T) => U
|
|
>arg : T
|
|
>T : T
|
|
>U : U
|
|
>y : (arg2: T) => U
|
|
>arg2 : T
|
|
>T : T
|
|
>U : U
|
|
>r : T
|
|
>T : T
|
|
>U : U
|
|
|
|
a8 = b8; // ok
|
|
>a8 = b8 : new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U
|
|
>a8 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
|
|
>b8 : new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U
|
|
|
|
b8 = a8; // ok
|
|
>b8 = a8 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
|
|
>b8 : new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U
|
|
>a8 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
|
|
|
|
var b9: new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U;
|
|
>b9 : new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U
|
|
>T : T
|
|
>Base : Base
|
|
>U : U
|
|
>Derived : Derived
|
|
>x : (arg: T) => U
|
|
>arg : T
|
|
>T : T
|
|
>U : U
|
|
>y : (arg2: { foo: string; bing: number; }) => U
|
|
>arg2 : { foo: string; bing: number; }
|
|
>foo : string
|
|
>bing : number
|
|
>U : U
|
|
>r : T
|
|
>T : T
|
|
>U : U
|
|
|
|
a9 = b9; // ok
|
|
>a9 = b9 : new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U
|
|
>a9 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
|
|
>b9 : new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U
|
|
|
|
b9 = a9; // ok
|
|
>b9 = a9 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
|
|
>b9 : new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U
|
|
>a9 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
|
|
|
|
var b10: new <T extends Derived>(...x: T[]) => T;
|
|
>b10 : new <T extends Derived>(...x: T[]) => T
|
|
>T : T
|
|
>Derived : Derived
|
|
>x : T[]
|
|
>T : T
|
|
>T : T
|
|
|
|
a10 = b10; // ok
|
|
>a10 = b10 : new <T extends Derived>(...x: T[]) => T
|
|
>a10 : new (...x: Derived[]) => Derived
|
|
>b10 : new <T extends Derived>(...x: T[]) => T
|
|
|
|
b10 = a10; // ok
|
|
>b10 = a10 : new (...x: Derived[]) => Derived
|
|
>b10 : new <T extends Derived>(...x: T[]) => T
|
|
>a10 : new (...x: Derived[]) => Derived
|
|
|
|
var b11: new <T extends Base>(x: T, y: T) => T;
|
|
>b11 : new <T extends Base>(x: T, y: T) => T
|
|
>T : T
|
|
>Base : Base
|
|
>x : T
|
|
>T : T
|
|
>y : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a11 = b11; // ok
|
|
>a11 = b11 : new <T extends Base>(x: T, y: T) => T
|
|
>a11 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base
|
|
>b11 : new <T extends Base>(x: T, y: T) => T
|
|
|
|
b11 = a11; // ok
|
|
>b11 = a11 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base
|
|
>b11 : new <T extends Base>(x: T, y: T) => T
|
|
>a11 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base
|
|
|
|
var b12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>;
|
|
>b12 : new <T extends Base[]>(x: Base[], y: T) => Derived[]
|
|
>T : T
|
|
>Array : T[]
|
|
>Base : Base
|
|
>x : Base[]
|
|
>Array : T[]
|
|
>Base : Base
|
|
>y : T
|
|
>T : T
|
|
>Array : T[]
|
|
>Derived : Derived
|
|
|
|
a12 = b12; // ok
|
|
>a12 = b12 : new <T extends Base[]>(x: Base[], y: T) => Derived[]
|
|
>a12 : new (x: Base[], y: Derived2[]) => Derived[]
|
|
>b12 : new <T extends Base[]>(x: Base[], y: T) => Derived[]
|
|
|
|
b12 = a12; // ok
|
|
>b12 = a12 : new (x: Base[], y: Derived2[]) => Derived[]
|
|
>b12 : new <T extends Base[]>(x: Base[], y: T) => Derived[]
|
|
>a12 : new (x: Base[], y: Derived2[]) => Derived[]
|
|
|
|
var b13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T;
|
|
>b13 : new <T extends Derived[]>(x: Base[], y: T) => T
|
|
>T : T
|
|
>Array : T[]
|
|
>Derived : Derived
|
|
>x : Base[]
|
|
>Array : T[]
|
|
>Base : Base
|
|
>y : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a13 = b13; // ok
|
|
>a13 = b13 : new <T extends Derived[]>(x: Base[], y: T) => T
|
|
>a13 : new (x: Base[], y: Derived[]) => Derived[]
|
|
>b13 : new <T extends Derived[]>(x: Base[], y: T) => T
|
|
|
|
b13 = a13; // ok
|
|
>b13 = a13 : new (x: Base[], y: Derived[]) => Derived[]
|
|
>b13 : new <T extends Derived[]>(x: Base[], y: T) => T
|
|
>a13 : new (x: Base[], y: Derived[]) => Derived[]
|
|
|
|
var b14: new <T>(x: { a: T; b: T }) => T;
|
|
>b14 : new <T>(x: { a: T; b: T; }) => T
|
|
>T : T
|
|
>x : { a: T; b: T; }
|
|
>a : T
|
|
>T : T
|
|
>b : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a14 = b14; // ok
|
|
>a14 = b14 : new <T>(x: { a: T; b: T; }) => T
|
|
>a14 : new (x: { a: string; b: number; }) => Object
|
|
>b14 : new <T>(x: { a: T; b: T; }) => T
|
|
|
|
b14 = a14; // ok
|
|
>b14 = a14 : new (x: { a: string; b: number; }) => Object
|
|
>b14 : new <T>(x: { a: T; b: T; }) => T
|
|
>a14 : new (x: { a: string; b: number; }) => Object
|
|
|
|
var b15: new <T>(x: T) => T[];
|
|
>b15 : new <T>(x: T) => T[]
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a15 = b15; // ok
|
|
>a15 = b15 : new <T>(x: T) => T[]
|
|
>a15 : { new (x: number): number[]; new (x: string): string[]; }
|
|
>b15 : new <T>(x: T) => T[]
|
|
|
|
b15 = a15; // ok
|
|
>b15 = a15 : { new (x: number): number[]; new (x: string): string[]; }
|
|
>b15 : new <T>(x: T) => T[]
|
|
>a15 : { new (x: number): number[]; new (x: string): string[]; }
|
|
|
|
var b16: new <T extends Base>(x: T) => number[];
|
|
>b16 : new <T extends Base>(x: T) => number[]
|
|
>T : T
|
|
>Base : Base
|
|
>x : T
|
|
>T : T
|
|
|
|
a16 = b16; // ok
|
|
>a16 = b16 : new <T extends Base>(x: T) => number[]
|
|
>a16 : { new <T extends Derived>(x: T): number[]; new <U extends Base>(x: U): number[]; }
|
|
>b16 : new <T extends Base>(x: T) => number[]
|
|
|
|
b16 = a16; // ok
|
|
>b16 = a16 : { new <T extends Derived>(x: T): number[]; new <U extends Base>(x: U): number[]; }
|
|
>b16 : new <T extends Base>(x: T) => number[]
|
|
>a16 : { new <T extends Derived>(x: T): number[]; new <U extends Base>(x: U): number[]; }
|
|
|
|
var b17: new <T>(x: new (a: T) => T) => T[]; // ok
|
|
>b17 : new <T>(x: new (a: T) => T) => T[]
|
|
>T : T
|
|
>x : new (a: T) => T
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a17 = b17; // ok
|
|
>a17 = b17 : new <T>(x: new (a: T) => T) => T[]
|
|
>a17 : { new (x: new (a: number) => number): number[]; new (x: new (a: string) => string): string[]; }
|
|
>b17 : new <T>(x: new (a: T) => T) => T[]
|
|
|
|
b17 = a17; // ok
|
|
>b17 = a17 : { new (x: new (a: number) => number): number[]; new (x: new (a: string) => string): string[]; }
|
|
>b17 : new <T>(x: new (a: T) => T) => T[]
|
|
>a17 : { new (x: new (a: number) => number): number[]; new (x: new (a: string) => string): string[]; }
|
|
|
|
var b18: new <T>(x: new (a: T) => T) => T[];
|
|
>b18 : new <T>(x: new (a: T) => T) => T[]
|
|
>T : T
|
|
>x : new (a: T) => T
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a18 = b18; // ok
|
|
>a18 = b18 : new <T>(x: new (a: T) => T) => T[]
|
|
>a18 : { new (x: { new (a: number): number; new (a: string): string; }): any[]; new (x: { new (a: boolean): boolean; new (a: Date): Date; }): any[]; }
|
|
>b18 : new <T>(x: new (a: T) => T) => T[]
|
|
|
|
b18 = a18; // ok
|
|
>b18 = a18 : { new (x: { new (a: number): number; new (a: string): string; }): any[]; new (x: { new (a: boolean): boolean; new (a: Date): Date; }): any[]; }
|
|
>b18 : new <T>(x: new (a: T) => T) => T[]
|
|
>a18 : { new (x: { new (a: number): number; new (a: string): string; }): any[]; new (x: { new (a: boolean): boolean; new (a: Date): Date; }): any[]; }
|
|
|