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;