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

typescript не работает автодополнение #13

Closed
Bobrovskih opened this issue Apr 27, 2018 · 8 comments
Closed

typescript не работает автодополнение #13

Bobrovskih opened this issue Apr 27, 2018 · 8 comments

Comments

@Bobrovskih
Copy link

не работает автодополнение
и появляется ошибка при попытке считать свойство ctx.message.from
[ts] Type 'Message | undefined' has no property 'from' and no string index signature.

image

typescript 2.8.3
telegram-typings 3.6.0

@Piterden
Copy link
Collaborator

Piterden commented Apr 27, 2018

const { from } = ctx;

Ой не, я гоню, это только под Telegraf.js работает...

Пробовали дебажить то?

@Piterden
Copy link
Collaborator

Piterden commented Apr 27, 2018

image
Я так думаю, что нужно все проверить. Не только message.

https://github.com/telegraf/telegraf/blob/develop/core/context.js#L110-L120

@sergeysova
Copy link
Owner

@Bobrovskih судя по документации https://core.telegram.org/bots/api#message, поле from опциональное и его нужно проверять на if (from) {

а вот то, что там Message вместо User, я проверю. Спасибо

@sergeysova
Copy link
Owner

В версии 3.6.0 всё правильно

https://github.com/sergeysova/telegram-typings/blob/v3.6.0/javascript/index.d.ts#L251

@Piterden
Copy link
Collaborator

Piterden commented Apr 27, 2018

Так а он Message'ю называет ctx.message, а не from...

const message = ctx.message
  || ctx.edited_message
  || ctx.channel_post
  || ctx.edited_channel_post
//  || ctx.inline_query
//  || ctx.chosen_inline_result
//  || ctx.callback_query
//  || ctx.shipping_query
//  || ctx.pre_checkout_query

const { from } = message

@sergeysova
Copy link
Owner

@Piterden автор вопроса юзает именно ctx.message

@Bobrovskih
Copy link
Author

if (from) { ... } помогает, спасибо

@Piterden
Copy link
Collaborator

А покажи куда ты вставил условие, @Bobrovskih
Чет я не вкурил...

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

3 participants