TypeScript/tests/baselines/reference/optionalFunctionArgAssignability.errors.txt
2014-07-12 17:30:19 -07:00

15 lines
1 KiB
Plaintext

==== tests/cases/compiler/optionalFunctionArgAssignability.ts (1 errors) ====
interface Promise<T> {
then<U>(onFulfill?: (value: T) => U, onReject?: (reason: any) => U): Promise<U>;
}
var a = function then<U>(onFulfill?: (value: string) => U, onReject?: (reason: any) => U): Promise<U> { return null };
var b = function then<U>(onFulFill?: (value: number) => U, onReject?: (reason: any) => U): Promise<U> { return null };
a = b; // error because number is not assignable to string
~
!!! Type '<U>(onFulFill?: (value: number) => U, onReject?: (reason: any) => U) => Promise<U>' is not assignable to type '<U>(onFulfill?: (value: string) => U, onReject?: (reason: any) => U) => Promise<U>':
!!! Types of parameters 'onFulFill' and 'onFulfill' are incompatible:
!!! Type '(value: number) => any' is not assignable to type '(value: string) => any':
!!! Types of parameters 'value' and 'value' are incompatible:
!!! Type 'number' is not assignable to type 'string'.