From ee72657bc8b58e32a0e8a874c6a9e05daeebd085 Mon Sep 17 00:00:00 2001 From: Omar Shahine <10343873+omarshahine@users.noreply.github.com> Date: Sun, 19 Apr 2026 15:27:05 +0000 Subject: [PATCH] bluebubbles: drop unused generic on requestJson, narrow at callsite --- extensions/bluebubbles/src/client.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/extensions/bluebubbles/src/client.ts b/extensions/bluebubbles/src/client.ts index 2454f03f05d..a00705dba36 100644 --- a/extensions/bluebubbles/src/client.ts +++ b/extensions/bluebubbles/src/client.ts @@ -263,18 +263,18 @@ export class BlueBubblesClient { * JSON request helper. Returns both the response (for status/headers) and * parsed body (null on non-ok or parse failure — callers check both). */ - async requestJson(params: { + async requestJson(params: { method: string; path: string; body?: unknown; timeoutMs?: number; - }): Promise<{ response: Response; data: T | null }> { + }): Promise<{ response: Response; data: unknown }> { const response = await this.request(params); if (!response.ok) { return { response, data: null }; } - const raw = await response.json().catch(() => null); - return { response, data: (raw as T | null) ?? null }; + const raw: unknown = await response.json().catch(() => null); + return { response, data: raw }; } /** @@ -365,17 +365,19 @@ export class BlueBubblesClient { messageGuid: string; timeoutMs?: number; }): Promise { - const { response, data } = await this.requestJson<{ - data?: Record; - }>({ + const { response, data } = await this.requestJson({ method: "GET", path: `/api/v1/message/${encodeURIComponent(params.messageGuid)}`, timeoutMs: params.timeoutMs, }); - if (!response.ok || !data?.data) { + if (!response.ok || typeof data !== "object" || data === null) { return []; } - return extractAttachments(data.data); + const inner = (data as { data?: unknown }).data; + if (typeof inner !== "object" || inner === null) { + return []; + } + return extractAttachments(inner as Record); } /**