Type error at custom fetch function for tRPC client

Hey. I'm running an Electron app as my front end. I used tRPC for the API which will communicate with my back-end, all good there. However, since it's an Electron app, I needed to give it a fetch function otherwise I get this error:
3 Replies
domi?
domi?2y ago
So I added electron-fetch to the createTRPCProxyClient() options, and it seems to work fine.
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import fetch from 'electron-fetch';

const trpc = createTRPCProxyClient<TrpcRouter>({
links: [
httpBatchLink({
url: '...',
// @ts-expect-error
fetch
})
]
});
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import fetch from 'electron-fetch';

const trpc = createTRPCProxyClient<TrpcRouter>({
links: [
httpBatchLink({
url: '...',
// @ts-expect-error
fetch
})
]
});
However, the types of the fetch function from electron-fetch don't seem to like the types expected by httpBatchLink from tRPC. (hence the @ts-expect-error)
domi?
domi?2y ago
domi?
domi?2y ago
My question is, is this something that could create a problem later on, or is this something that would be fine to just @ts-ignore. (If I ignore it, it seems to work fine as of now.)
Want results from more Discord servers?
Add your server