111 lines
No EOL
8.7 KiB
Text
111 lines
No EOL
8.7 KiB
Text
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 'string' is not assignable to type 'number'.
|
|
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 'string' is not assignable to type 'number'.
|
|
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 'string' is not assignable to type 'number'.
|
|
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 'number' is not assignable to type 'string'.
|
|
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 'number' is not assignable to type 'string'.
|
|
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 'string' is not assignable to type 'number'.
|
|
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 'number' is not assignable to type 'string'.
|
|
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 'number' is not assignable to type 'string'.
|
|
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 'string' is not assignable to type 'number'.
|
|
|
|
|
|
==== 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 'string' is not assignable to type 'number'.
|
|
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 'string' is not assignable to type 'number'.
|
|
|
|
|
|
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 'string' is not assignable to type 'number'.
|
|
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 'number' is not assignable to type 'string'.
|
|
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 'number' is not assignable to type 'string'.
|
|
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 'string' is not assignable to type 'number'.
|
|
|
|
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 'number' is not assignable to type 'string'.
|
|
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 'number' is not assignable to type 'string'.
|
|
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 'string' is not assignable to type 'number'. |