fix: TypeScript type for onWhatsApp (allow undefined return)

This commit is contained in:
Bob (AI Agent) 2026-01-29 20:41:22 +00:00
parent 5fc974ef20
commit c4183e2ce6
2 changed files with 6 additions and 3 deletions

View File

@ -119,7 +119,7 @@ interface OnWhatsAppResult {
} }
interface SockWithOnWhatsApp { interface SockWithOnWhatsApp {
onWhatsApp?: (jid: string) => Promise<OnWhatsAppResult[]>; onWhatsApp?: (jid: string) => Promise<OnWhatsAppResult[] | undefined>;
} }
/** /**

View File

@ -13,7 +13,7 @@ export function createWebSendApi(params: {
sock: { sock: {
sendMessage: (jid: string, content: AnyMessageContent) => Promise<unknown>; sendMessage: (jid: string, content: AnyMessageContent) => Promise<unknown>;
sendPresenceUpdate: (presence: WAPresence, jid?: string) => Promise<unknown>; sendPresenceUpdate: (presence: WAPresence, jid?: string) => Promise<unknown>;
onWhatsApp?: (jid: string) => Promise<OnWhatsAppResult[]>; onWhatsApp?: (jid: string) => Promise<OnWhatsAppResult[] | undefined>;
}; };
defaultAccountId: string; defaultAccountId: string;
}) { }) {
@ -23,7 +23,10 @@ export function createWebSendApi(params: {
try { try {
return await resolveBrazilianJid(params.sock, jid); return await resolveBrazilianJid(params.sock, jid);
} catch (err) { } catch (err) {
console.warn('[send-api] Brazil JID resolution failed, using original:', (err as Error).message); console.warn(
"[send-api] Brazil JID resolution failed, using original:",
(err as Error).message,
);
return jid; return jid;
} }
} }