From d898ad6807bc2a737039f78bd34f655ad4055859 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 6 Feb 2026 15:45:34 -0800 Subject: [PATCH] fix(telegram): cast fetch for grammY ApiClientOptions --- src/telegram/bot.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/telegram/bot.ts b/src/telegram/bot.ts index 884e222b1..cdb811265 100644 --- a/src/telegram/bot.ts +++ b/src/telegram/bot.ts @@ -128,6 +128,9 @@ export function createTelegramBot(opts: TelegramBotOptions) { network: telegramCfg.network, }); const shouldProvideFetch = Boolean(fetchImpl); + // grammY's ApiClientOptions types still track `node-fetch` types; Node 22+ global fetch + // (undici) is structurally compatible at runtime but not assignable in TS. + const fetchForClient = fetchImpl as unknown as NonNullable; const timeoutSeconds = typeof telegramCfg?.timeoutSeconds === "number" && Number.isFinite(telegramCfg.timeoutSeconds) ? Math.max(1, Math.floor(telegramCfg.timeoutSeconds)) @@ -135,7 +138,7 @@ export function createTelegramBot(opts: TelegramBotOptions) { const client: ApiClientOptions | undefined = shouldProvideFetch || timeoutSeconds ? { - ...(shouldProvideFetch && fetchImpl ? { fetch: fetchImpl } : {}), + ...(shouldProvideFetch && fetchImpl ? { fetch: fetchForClient } : {}), ...(timeoutSeconds ? { timeoutSeconds } : {}), } : undefined;