A local-first personal finance app
:bug: (typescript) patching sendCatch type (#2343)
Matiss Janis Aboltinsb1b266e83caa
diff --git a/packages/loot-core/src/platform/client/fetch/index.d.ts b/packages/loot-core/src/platform/client/fetch/index.d.tsindex 5ae4f2d3e9..7ca6e52bc8 100644--- a/packages/loot-core/src/platform/client/fetch/index.d.ts+++ b/packages/loot-core/src/platform/client/fetch/index.d.ts@@ -4,6 +4,14 @@ import type { ServerEvents } from '../../../types/server-events';export function init(socketName: string): Promise<unknown>;export type Init = typeof init;+export function send<K extends keyof Handlers>(+ name: K,+ args?: Parameters<Handlers[K]>[0],+ options?: { catchErrors: true },+): ReturnType<+ | { data: Handlers[K] }+ | { error: { type: 'APIError' | 'InternalError'; message: string } }+>;export function send<K extends keyof Handlers>(name: K,args?: Parameters<Handlers[K]>[0],@@ -14,7 +22,10 @@ export type Send = typeof send;export function sendCatch<K extends keyof Handlers>(name: K,args?: Parameters<Handlers[K]>[0],-): ReturnType<Handlers[K]>;+): ReturnType<+ | { data: Handlers[K] }+ | { error: { type: 'APIError' | 'InternalError'; message: string } }+>;export type SendCatch = typeof sendCatch;export function listen<K extends keyof ServerEvents>(diff --git a/packages/loot-core/src/platform/client/fetch/index.web.ts b/packages/loot-core/src/platform/client/fetch/index.web.tsindex 055871e885..c74ce488a6 100644--- a/packages/loot-core/src/platform/client/fetch/index.web.ts+++ b/packages/loot-core/src/platform/client/fetch/index.web.ts@@ -78,7 +78,6 @@ export const init: T.Init = async function () {return new Promise(connectSocket);};-// @ts-expect-error Figure out why typechecker is suddenly breaking hereexport const send: T.Send = function (name,args,diff --git a/upcoming-release-notes/2343.md b/upcoming-release-notes/2343.mdnew file mode 100644index 0000000000..0466048df8--- /dev/null+++ b/upcoming-release-notes/2343.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Patching an incorrect TypeScript type definition used for `sendCatch` method return value.