Skip to content

Commit e486933

Browse files
🤖 Merge PR DefinitelyTyped#74621 [telegram-web-app] add support for Bot API 9.5; align BottomButton TSDoc with main documentation by @SecondThundeR
1 parent d7376a0 commit e486933

3 files changed

Lines changed: 76 additions & 24 deletions

File tree

‎types/telegram-web-app/index.d.ts‎

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -935,46 +935,73 @@ export interface BackButton {
935935
* Web App in the Telegram interface.
936936
*/
937937
export interface BottomButton {
938-
/** Current button text. Set to CONTINUE by default. */
938+
/**
939+
* **Bot API 9.5+**
940+
*
941+
* Unique identifier of the custom emoji shown
942+
* before the text of the button.
943+
*/
944+
iconCustomEmojiId: string;
945+
/**
946+
* Current button text. Set to _Continue_ for the main button and
947+
* _Cancel_ for the secondary button by default.
948+
*/
939949
text: string;
940-
/** Current button color. Set to themeParams.button_color by default. */
950+
/**
951+
* Current button color. Set to _themeParams.button_color_ for the main button
952+
* and _themeParams.bottom_bar_bg_color_ for the secondary button by default.
953+
*/
941954
color: string;
942955
/**
943-
* Current button text color. Set to themeParams.button_text_color by
944-
* default.
956+
* Current button text color. Set to
957+
* _themeParams.button_text_color_ for the main button and
958+
* _themeParams.button_color_ for the secondary button by default.
945959
*/
946960
textColor: string;
947-
/** Shows whether the button is visible. Set to false by default. */
961+
/** Shows whether the button is visible. Set to _false_ by default. */
948962
isVisible: boolean;
949-
/** Shows whether the button is active. Set to true by default. */
963+
/** Shows whether the button is active. Set to _true_ by default. */
950964
isActive: boolean;
951-
/** Shows whether the button has a shine effect. Set to false by default. */
965+
/**
966+
* **Bot API 7.10+**
967+
*
968+
* Shows whether the button has a shine effect. Set to _false_ by default.
969+
*/
952970
hasShineEffect: boolean;
953971
/**
972+
* **Bot API 7.10+**
973+
*
954974
* Position of the secondary button. Not defined for the main button.
955-
* It applies only if both the main and secondary buttons are visible. Set to left by default.
975+
* It applies only if both the main and secondary buttons are visible.
976+
* Set to _left_ by default.
977+
*
956978
* Supported values:
957-
* - left, displayed to the left of the main button,
958-
* - right, displayed to the right of the main button,
959-
* - top, displayed above the main button,
960-
* - bottom, displayed below the main button.
979+
* - _left_, displayed to the left of the main button,
980+
* - _right_, displayed to the right of the main button,
981+
* - _top_, displayed above the main button,
982+
* - _bottom_, displayed below the main button.
961983
*/
962984
position?: "left" | "right" | "top" | "bottom";
963-
/** Readonly. Shows whether the button is displaying a loading indicator. */
985+
/** _Readonly._ Shows whether the button is displaying a loading indicator. */
964986
isProgressVisible: boolean;
965987
/** A method to set the button text. */
966988
setText(text: string): BottomButton;
967989
/**
968-
* A method that sets the button press event handler. An alias for
969-
* Telegram.WebApp.onEvent('mainButtonClicked', callback)
990+
* A method that sets the button's press event handler.
991+
* An alias for `Telegram.WebApp.onEvent('mainButtonClicked', callback)`
970992
*/
971993
onClick(callback: () => void): BottomButton;
972-
/** A method that deletes a previously set handler */
994+
/**
995+
* A method that removes the button's press event handler.
996+
* An alias for `Telegram.WebApp.offEvent('mainButtonClicked', callback)`
997+
*/
973998
offClick(callback: () => void): BottomButton;
974999
/**
975-
* A method to make the button visible. Note that opening the Web App from
976-
* the attachment menu hides the main button until the user interacts with
977-
* the Web App interface.
1000+
* A method to make the button visible.
1001+
*
1002+
* _Note that opening the Web App from
1003+
* the {@link https://core.telegram.org/bots/webapps#launching-mini-apps-from-the-attachment-menu | attachment menu}
1004+
* hides the main button until the user interacts with the Web App interface._
9781005
*/
9791006
show(): BottomButton;
9801007
/** A method to hide the button. */
@@ -987,31 +1014,44 @@ export interface BottomButton {
9871014
* A method to show a loading indicator on the button. It is recommended to
9881015
* display loading progress if the action tied to the button may take a long
9891016
* time. By default, the button is disabled while the action is in progress.
990-
* If the parameter leaveActive=true is passed, the button remains enabled.
1017+
* If the parameter `leaveActive=true` is passed, the button remains enabled.
9911018
*/
9921019
showProgress(leaveActive?: boolean): BottomButton;
9931020
/** A method to hide the loading indicator. */
9941021
hideProgress(): BottomButton;
9951022
/**
9961023
* A method to set the button parameters. The params parameter is an object
9971024
* containing one or several fields that need to be changed:
1025+
* - icon_custom_emoji_id - `Bot API 9.5+` button icon emoji id;
9981026
* - text - button text;
9991027
* - color - button color;
10001028
* - text_color - button text color;
1029+
* - has_shine_effect - `Bot API 7.10+` enable shine effect;
1030+
* - position - position of the secondary button;
10011031
* - is_active - enable the button;
10021032
* - is_visible - show the button.
10031033
*/
1004-
setParams(params: MainButtonParams): BottomButton;
1034+
setParams(params: BottomButtonParams): BottomButton;
10051035
}
10061036

1007-
export interface MainButtonParams {
1037+
export interface BottomButtonParams {
1038+
/**
1039+
* **Bot API 9.5+**
1040+
*
1041+
* button icon emoji id
1042+
*/
1043+
icon_custom_emoji_id?: string;
10081044
/** button text */
10091045
text?: string;
10101046
/** button color */
10111047
color?: Color;
10121048
/** button text color */
10131049
text_color?: Color;
1014-
/** enable shine effect */
1050+
/**
1051+
* **Bot API 7.10+**
1052+
*
1053+
* enable shine effect
1054+
*/
10151055
has_shine_effect?: boolean;
10161056
/** position of the secondary button */
10171057
position?: "left" | "right" | "top" | "bottom";

‎types/telegram-web-app/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/telegram-web-app",
4-
"version": "9.1.9999",
4+
"version": "9.5.9999",
55
"nonNpm": "conflict",
66
"nonNpmDescription": "telegram-web-app",
77
"projects": ["https://telegram.org/js/telegram-web-app.js"],

‎types/telegram-web-app/telegram-web-app-tests.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,15 @@ app.isActive; // $ExpectType boolean
126126
app.isFullscreen; // $ExpectType boolean
127127

128128
app.isOrientationLocked; // $ExpectType boolean
129+
130+
app.MainButton.iconCustomEmojiId; // $ExpectType string
131+
132+
app.MainButton.setParams({
133+
icon_custom_emoji_id: "", // $ExpectType string
134+
});
135+
136+
app.SecondaryButton.iconCustomEmojiId; // $ExpectType string
137+
138+
app.SecondaryButton.setParams({
139+
icon_custom_emoji_id: "", // $ExpectType string
140+
});

0 commit comments

Comments
 (0)