Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add typescript type declarations #60

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

acran
Copy link
Contributor

@acran acran commented Feb 9, 2019

This change set adds type declarations to allow using this package in TypeScript projects while having full support for autocompletion and integrated API documentation.

It also fixes some bugs I discovered along the way, mostly missing parameters/documentation in code comments.

although already used when setting up webhooks, the parameters
allowed_updates and max_connections were actually never passed to the
api.
The certificate and privateKey are required values since they're used
unconditionally when using webhooks.
The url and host are optional but at least one of them has to be defined
and using '0.0.0.0' as a default value for host would cause an invalid
url to be autogenerated otherwise.
reply_markup actually only accepts JSON-serialized objects. For user
convenience simply JSON.stringify() passed objects on demand.
This adds type declarations to the library making it fully typed for
TypeScript support
The request data was actually serialized as multipart/form-data instead
of a JSON body. Passing JSON data with a boolean value then throw an
error while serializing:

bot.sendMessage({
	chat_id: user.id,
	text: text,
	disable_web_page_preview: false, // throws an error
});

// > TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string or Buffer. Received type boolean
@acran acran force-pushed the typings branch 2 times, most recently from 525cc20 to b09a7e6 Compare February 16, 2019 13:59
acran added a commit to acran/AcademyConsultBot that referenced this pull request Feb 16, 2019
Die neuste Version enthält die nötigen type decalarations mit den type
annotations für alle Funktionen der Library.

siehe mast/telegram-bot-api#60
@acran
Copy link
Contributor Author

acran commented Mar 20, 2019

@mast: shamelessly pushing this PR again

@saitho
Copy link

saitho commented Oct 27, 2020

@mast Are you planning to add TypeScript support for this package? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants