1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(13,5): error TS2322: Type '(...args: string[]) => number' is not assignable to type '(...args: number[]) => number'.
Types of parameters 'args' and 'args' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(17,5): error TS2322: Type '(x?: string) => number' is not assignable to type '(...args: number[]) => number'.
Types of parameters 'x' and 'args' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(26,5): error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x: number, ...z: number[]) => number'.
Types of parameters 'args' and 'z' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(35,5): error TS2322: Type '(x: number, y?: number, z?: number) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
Types of parameters 'y' and 'y' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(36,5): error TS2322: Type '(x: number, ...z: number[]) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
Types of parameters 'z' and 'y' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(37,5): error TS2322: Type '(x: string, y?: string, z?: string) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
Types of parameters 'x' and 'x' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(41,5): error TS2322: Type '(x?: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
Types of parameters 'y' and 'y' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(43,5): error TS2322: Type '(x: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
Types of parameters 'y' and 'y' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(45,5): error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
Types of parameters 'args' and 'z' are incompatible.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts (9 errors) ====
// call signatures in derived types must have the same or fewer optional parameters as the target for assignment
interface Base {
a: (...args: number[]) => number;
a2: (x: number, ...z: number[]) => number;
a3: (x: number, y?: string, ...z: number[]) => number;
a4: (x?: number, y?: string, ...z: number[]) => number;
}
var a: (...args: number[]) => number; // ok, same number of required params
a = () => 1; // ok, same number of required params
a = (...args: number[]) => 1; // ok, same number of required params
a = (...args: string[]) => 1; // error, type mismatch
~
!!! error TS2322: Type '(...args: string[]) => number' is not assignable to type '(...args: number[]) => number'.
!!! error TS2322: Types of parameters 'args' and 'args' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a = (x?: number) => 1; // ok, same number of required params
a = (x?: number, y?: number, z?: number) => 1; // ok, same number of required params
a = (x: number) => 1; // ok, rest param corresponds to infinite number of params
a = (x?: string) => 1; // error, incompatible type
~
!!! error TS2322: Type '(x?: string) => number' is not assignable to type '(...args: number[]) => number'.
!!! error TS2322: Types of parameters 'x' and 'args' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
var a2: (x: number, ...z: number[]) => number;
a2 = () => 1; // ok, fewer required params
a2 = (...args: number[]) => 1; // ok, fewer required params
a2 = (x?: number) => 1; // ok, fewer required params
a2 = (x: number) => 1; // ok, same number of required params
a2 = (x: number, ...args: number[]) => 1; // ok, same number of required params
a2 = (x: number, ...args: string[]) => 1; // should be type mismatch error
~~
!!! error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x: number, ...z: number[]) => number'.
!!! error TS2322: Types of parameters 'args' and 'z' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a2 = (x: number, y: number) => 1; // ok, rest param corresponds to infinite number of params
a2 = (x: number, y?: number) => 1; // ok, same number of required params
var a3: (x: number, y?: string, ...z: number[]) => number;
a3 = () => 1; // ok, fewer required params
a3 = (x?: number) => 1; // ok, fewer required params
a3 = (x: number) => 1; // ok, same number of required params
a3 = (x: number, y: string) => 1; // ok, all present params match
a3 = (x: number, y?: number, z?: number) => 1; // error
~~
!!! error TS2322: Type '(x: number, y?: number, z?: number) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
a3 = (x: number, ...z: number[]) => 1; // error
~~
!!! error TS2322: Type '(x: number, ...z: number[]) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
!!! error TS2322: Types of parameters 'z' and 'y' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
a3 = (x: string, y?: string, z?: string) => 1; // error
~~
!!! error TS2322: Type '(x: string, y?: string, z?: string) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
var a4: (x?: number, y?: string, ...z: number[]) => number;
a4 = () => 1; // ok, fewer required params
a4 = (x?: number, y?: number) => 1; // error, type mismatch
~~
!!! error TS2322: Type '(x?: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
a4 = (x: number) => 1; // ok, all present params match
a4 = (x: number, y?: number) => 1; // error, second param has type mismatch
~~
!!! error TS2322: Type '(x: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
a4 = (x?: number, y?: string) => 1; // ok, same number of required params with matching types
a4 = (x: number, ...args: string[]) => 1; // error, rest params have type mismatch
~~
!!! error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
!!! error TS2322: Types of parameters 'args' and 'z' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|