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 definition #71

Closed
SoilChang opened this issue Feb 8, 2017 · 23 comments
Closed

typescript definition #71

SoilChang opened this issue Feb 8, 2017 · 23 comments

Comments

@SoilChang
Copy link

Is it possible to add in typescript definition for this library? It would make development much easier.

@dotcypress
Copy link
Member

dotcypress commented Feb 8, 2017

Hey.

It's absolutely possible 👍

PR is highly welcome.

@sergeysova
Copy link
Contributor

sergeysova commented Mar 31, 2017

And flowtype?

@mRs-
Copy link

mRs- commented May 28, 2017

Hey, what's the current status? Would like to use TypeScript with this lib :)

@flaticols
Copy link

Hey! I'm started to write .d.ts. After few days plan PR.

@mRs-
Copy link

mRs- commented Jun 19, 2017 via email

@sergeysova
Copy link
Contributor

sergeysova commented Jul 28, 2017

I'm started working on typescript typings.
Please, contribute: https://github.com/sergeysova/telegraf/tree/typings

https://github.com/sergeysova/telegraf/blob/typings/typings/telegraf.d.ts

2K lines of typings is ready now

@elementh
Copy link

Any update on the current status of this issue?

@cschmidli
Copy link

cschmidli commented Nov 12, 2017

could we merge the work of @sergeysova to the main repo?

@sergeysova
Copy link
Contributor

@SoilChang @mRs- @flaticols @elementh @sagax85

Welcome to feature/typings branch

PR: #245

@TheServat
Copy link

how can i use this at the moment?

@j-maas
Copy link

j-maas commented Dec 3, 2017

@sajjad-ser I managed to get it to work by telling npm to fetch the branch directly from GitHub instead of the npm package in the package.json:

"dependencies": {
   ...
   "telegraf": "telegraf/telegraf#feature/typings"
}

If you would like to see an example, you can check out my bot at https://github.com/Y0hy0h/secret-santa-bot/tree/typescript.

@j-maas
Copy link

j-maas commented Dec 5, 2017

Is it a good idea to port all of Telegraf to TypeScript? That way, the would be no way that the typings could mismatch the library.

@sergeysova
Copy link
Contributor

Full telegram bot types parsed and stored in telegram-typings

https://github.com/sergeysova/telegram-typings/blob/master/javascript/index.d.ts

@j-maas
Copy link

j-maas commented Dec 27, 2017

Are there any examples of Telegraf bots using TypeScript? I'm having trouble setting it up.

@j-c-levin
Copy link

@y0hy0h If it helps, I'm working on one now

https://github.com/j-c-levin/notcatbot

@divyenduz
Copy link

Is there any way I can help in moving this forward?

@Piterden
Copy link
Contributor

Piterden commented Aug 23, 2018

Guys, there is one bot which needs to be rewritten. syntax-highlighter-bot

The structure smells fishy there for now, however, in the past it smelled stronger old-double-bot

The old double bot was written by @CristianOspina and he is da shit (I mean a positive connotation) because that bot would be the good exhibit for the museum.

I sure that functionality is a good idea to implement it with TS.

I wonder the new structure would be similar to my template-bot:

 ├── migrations/
 ├── src/
 │  ├── handlers/
 │  │  ├── help/
 │  │  │  └── index.js
 │  │  ├── settings/
 │  │  │  └── index.js
 │  │  ├── start/
 │  │  │  └── index.js
 │  │  └── index.js
 │  ├── helpers/
 │  │  ├── debug/
 │  │  │  └── index.js
 │  │  └── index.js
 │  ├── keyboards/
 │  │  └── index.js
 │  ├── scenes/
 │  │  └── index.js
 │  └── index.js
 ├── .gitignore
 ├── knexfile.js
 ├── LICENSE
 ├── README.md
 └── package.json

I would be happy if you will try to write this code, @divyenduz

@y0hy0h there is a way, unfortunately... Markup of that page is changing permanently and parser logic needs to be corrected from time to time. There is the initial version. As you could see the start code now is parsing only a small part.

@GingerPlusPlus no need to worries, bro ;)

@shurygindv
Copy link

shurygindv commented May 1, 2019

Hi, guys, help! Probably, is there a missing type definition in index.d.ts file:
870: export interface Telegraf<TContext extends ContextMessageUpdate> extends Composer<TContext>
Interface doesn't have an '.action(...)' method, yep, it has in here
788: export interface ComposerConstructor, but not in 740: export interface Composer<TContext extends ContextMessageUpdate> { (in the same time Telegraf extends exactly Composer instead ComposerConstructor interface)

p.s in js: class Telegraf extends Composer (it has such interface), I don't feel right till post about that, thank you!

p.s update: ctx.reply accepts second argument as ExtraReplyMessage | undefined, in the same time method Extra.markup() -> returns just Extra type and happens conflict when I will do so (ctx.reply('Hi', Extra.markup(..)) - it works in plain JS, but a little bit incorrect moment in ts, maybe

p.s update: Markup.inlineKeyboard(... , options) works pretty well with one argument, in my example CallbackButtons[] as Markup.inlineKeyboards(buttons), but it strictly requires and second argument 'options', does it make sense? Also Markup.callbackButton requires three arguments, but if I provide only two - it works, but it warns me that I didn't pass 'hidden: boolean(3)' flag (3 arg, maybe it's optional?),

Extra.markup((m: Markup): InlineKeyboardMarkup => m.inlineKeyboards(buttons)) <- errors, where options (2 argument)?, but it works :)

also I can't import/use scene/stage, they missed in index.d.ts file

@mxvsh
Copy link

mxvsh commented Oct 1, 2019

I'm started working on typescript typings.
Please, contribute: https://github.com/sergeysova/telegraf/tree/typings

https://github.com/sergeysova/telegraf/blob/typings/typings/telegraf.d.ts

2K lines of typings is ready now

all repositories has been removed, why? 😢

@Piterden
Copy link
Contributor

Piterden commented Oct 1, 2019

@thedevxen take a look

@divyenduz
Copy link

@Piterden Ooops! I just saw today (because of the latest changes) for some reason that I got mentioned in that last comment. Is this work still to be done? Happy to pick that up if it is still there.

@Piterden
Copy link
Contributor

Piterden commented Oct 1, 2019

@divyenduz sorry I don't understand what you are talking about

@divyenduz
Copy link

This message has

I would be happy if you will try to write this code, @divyenduz

I am sorry that missed it earlier, happy to help if this is still a task :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests