diff --git a/packages/loot-core/src/platform/client/fetch/index.d.ts b/packages/loot-core/src/platform/client/fetch/index.d.ts index 5ae4f2d3e91579176980db9930aea9894eb73f45..7ca6e52bc8b469b615d904a55aea45067af0a66d 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.ts index 055871e885a2f2b74dc5d41c6dfffbcf0f3d957e..c74ce488a6f873d3468b3c900b91a01b5cc387ee 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 here export const send: T.Send = function ( name, args, diff --git a/upcoming-release-notes/2343.md b/upcoming-release-notes/2343.md new file mode 100644 index 0000000000000000000000000000000000000000..0466048df86242dddf326d55fe2cbb7c25790874 --- /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.