From 4f1887a79156dcf16491accc35d1f4a4a914dea7 Mon Sep 17 00:00:00 2001 From: Vladimir Ilyin <66038379+wishyoudie@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:47:56 +0300 Subject: [PATCH] Fix requestContact typing --- index.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 9742d78..b7dd4f6 100644 --- a/index.ts +++ b/index.ts @@ -93,6 +93,29 @@ export interface CloudStorage { ) => void; } +export type Contact = { + first_name?: string; + last_name?: string; + phone_number: string; + user_id: number; +} + +export type RequestContactResponse = { +} & ( + | { + status: "sent"; + response: string; + hash: string; + responseUnsafe: { + auth_date: string; + contact: Contact; + } + } + | { + status: "cancelled"; + } +); + export interface BackButton { isVisible: boolean; show: VoidFunction; @@ -258,7 +281,7 @@ export interface WebApp { chooseChatTypes?: Array<"users" | "bots" | "groups" | "channels"> ) => void; requestWriteAccess: (callback?: (access: boolean) => unknown) => void; - requestContact: (callback?: (access: boolean) => unknown) => void; + requestContact: (callback?: (access: boolean, response?: RequestContactResponse) => unknown) => void; } export interface Telegram {