I have been stuck with this typescript error for the past days.
Cannot invoke an expression whose type lacks a call signature. Type '(<TResult1 = ApiResponse, TResult2 = never>(onfulfilled?: ((value: ApiResponse) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | null | undefined) => Promise<...>) | (<TResult1 = void, TResult2 = never>(onfulfilled?: ((va...' has no compatible call signatures.
Code:
const getDetailsPromise = myCode
? storeApi.getDetails(params, [myCode])
: Promise.resolve();
return getDetailsPromise.then(
(result: ApiResponse | void) => {
.......Some logic
.......Some logic
return Promise.resolve<
[MethodResponse, ResponseHeaders]
>([ShippingResponse, response.headers]);
}
);
storeApi.js
getDetails(
requestParams: RequestParams,
myCode: string[]
): Promise<ApiResponse> {
.......Some logic
.......Some logic
}
Here getDetailsPromise returns either Promise or Promise. Also we are expecting myCode type as string if value exists. I am getting the above mentioned error while trying to build the application. Can somebody help/guide me to fix this issue? Any help would be really appreciated.
Thanks in advance!
Thanks to Anatoly. I changed the return type in a wrapper as a Promise with a union type instead of a union of Promise-d types.