You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I should be able to also pass in a FetchMockSandbox to this function but typescript says that FetchMockSandbox and native fetch are incompatible:
error TS2345: Argument of type 'FetchMockSandbox' is not assignable to parameter of type '(input: URL | RequestInfo, init?: RequestInit | undefined) => Promise'.
I'm importing the type FetchMockSandbox from your client
When I inspect the FetchMockSandbox type I see this:
interfaceFetchMockSandboxextendsFetchMockStatic{/** * Also callable as fetch(). Use `typeof fetch` in your code to define * a field that accepts both `fetch()` and a fetch-mock sandbox. */(input?: string|Request,init?: RequestInit): Promise<Response>;}
I'm following your instructions from your own type definition and it does not work
typeof fetch and FetchMockSandbox are not compatible
The text was updated successfully, but these errors were encountered:
TLDR
FetchMockSandbox
is supposed to be a drop-in replacement forfetch
except that their types are incompatibleFetchMockSandbox
's first argumentinput
has a?
which allows it to beundefined
, nativefetch
does not.I have a function which accepts the
fetch
method as a parameter.I should be able to also pass in a
FetchMockSandbox
to this function but typescript says thatFetchMockSandbox
and nativefetch
are incompatible:I'm importing the type
FetchMockSandbox
from yourclient
versions I'm using:
This is the type info for
fetch
andRequestInfo
(inspecting types via vscode)When I inspect the
FetchMockSandbox
type I see this:I'm following your instructions from your own type definition and it does not work
typeof fetch
andFetchMockSandbox
are not compatibleThe text was updated successfully, but these errors were encountered: