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

Type for sendData method #3

Open
allofapiece opened this issue May 7, 2022 · 2 comments
Open

Type for sendData method #3

allofapiece opened this issue May 7, 2022 · 2 comments

Comments

@allofapiece
Copy link

ERROR in D:/myproject/node_modules/telegram-webapps-types/dist/index.d.ts(60,14):
60:14 Parameter 'data' implicitly has an 'any' type.
    58 |      * A method used to send data to the bot.
    59 |      */
  > 60 |     sendData(data): void;
       |              ^
    61 |     /**
    62 |      * A method that informs the Telegram app that the Web App is ready to be displayed.
    63 |      */
Version: typescript 3.9.9

Probably data argument should be type of WebAppData (https://core.telegram.org/bots/api#webappdata)

@prKassad
Copy link
Owner

prKassad commented May 8, 2022

I'm not sure that data should have type WebAppData. If you look at the implementation of https://telegram.org/js/telegram-web-app.js then date is most like a string.

  WebApp.sendData = function (data) {
    if (!data || !data.length) {
      console.error('[Telegram.WebApp] Data is required', data);
      throw Error('WebAppDataInvalid');
    }
    if (byteLength(data) > 4096) {
      console.error('[Telegram.WebApp] Data is too long', data);
      throw Error('WebAppDataInvalid');
    }
    WebView.postEvent('web_app_data_send', false, {data: data});
  };

@allofapiece
Copy link
Author

yep you're right

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

No branches or pull requests

2 participants