Search code examples
angular11typescript4.0

No overload matches this call. Overload 1 of 5, '(next: null | undefined, error: (error: any) => void, complete?: (() => void) | undefined): Subscript


I'm getting following error message while accessing assigning response from a variable.

Code:

enter image description here

Error:

enter image description here

No overload matches this call.
  Overload 1 of 5, '(next: null | undefined, error: (error: any) => void, complete?: (() => void) | undefined): Subscription', gave the following error.
    Argument of type '(response: Employee[]) => void' is not assignable to parameter of type 'null | undefined'.
      Type '(response: Employee[]) => void' is not assignable to type 'null'.
  Overload 2 of 5, '(next?: ((value: Employee) => void) | undefined, error?: ((error: any) => void) | undefined, complete?: (() => void) | undefined): Subscription', gave the following error.
    Argument of type '(response: Employee[]) => void' is not assignable to parameter of type '(value: Employee) => void'.
      Types of parameters 'response' and 'value' are incompatible.
        Type 'Employee' is missing the following properties from type 'Employee[]': length, pop, push, concat, and 26 more.ts(2769)

Solution

  • I found the mistake in this. Service method return type was mismatch with this one.