File: optionalFunctionArgAssignability.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 1,671 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
tests/cases/compiler/optionalFunctionArgAssignability.ts(7,1): error TS2322: 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: string) => any' is not assignable to type '(value: number) => any'.
      Types of parameters 'value' and 'value' are incompatible.
        Type 'number' is not assignable to type 'string'.


==== 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
    ~
!!! error TS2322: 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>'.
!!! error TS2322:   Types of parameters 'onFulFill' and 'onFulfill' are incompatible.
!!! error TS2322:     Type '(value: string) => any' is not assignable to type '(value: number) => any'.
!!! error TS2322:       Types of parameters 'value' and 'value' are incompatible.
!!! error TS2322:         Type 'number' is not assignable to type 'string'.