I’m returning an AxiosResponse object from a call to axios.get
in a generic function. That object has the shape:
interface AxiosResponse<T = any, D = any> {
data: T;
...
}
The get
call has this type:
get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
I’m hours into digging for an answer to fix this error:
I understand that the Awaited<R>
type was added in 4.5. I understand from other answers that the Awaited type should be unwrapped to R (from the accepted answer on that question):
If the type
T
you are awaiting is aPromise<U>
whereU
isn’t aPromise
of any kind, thenAwaited<T>
is the same asU
How do I fix this?
MODS: if you close this for being “duplicate”, please don’t post links to answers about Swift, or unrelated questions. I have little faith in SO so I expect you to do it anyway with a completely irrelevant question as what I’m duplicating. Surprise me; I’ve spent a lot of hours searching and didn’t find any duplicates.