-
Notifications
You must be signed in to change notification settings - Fork 647
Add type
field to Message
and Update
#93
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
Comments
This field is redundant in general. You can do that in Telegraf.JS on a framework level if you need this, |
Extra code running on every update, for straying away from the API? I'll pass. |
Extra redundant data sent to everyone over network would be much worse, so if it is needed for TypeScript, it can be added there. |
|
And to comply with the API, any extra field I'd add would have to be inaccessible to library users, limiting its usefulness. |
Not really. HTTP is used as a transport and API should be possible to use with different trasports. Moreover, special |
I feel like it's just exposing information you already have, in a more convenient format. I didn't expect push-back. Let me try to make a proper case: These extra fields would help users narrow down the update type (telegraf/telegraf#1319 (comment)). They'd also help TypeScript: since Adding the discriminants on my end is not worth the hassle: I cannot simply name it It's actually impossible to programmatically determine update type in a future-proof way. I'd have to use a allowlist or denylist of fields, which would get outdated with new API versions and break existing bots. It's even worse for |
These extra fields are redundant. For example, we wouldn't add separate fields
You can name it "message_type"/"update_type" or "_type". These names are safe.
You don't need to do that. You wouldn't be able to match them to a specific type anyway. You can mark all messages without content or with content of unknown type as "unknown" or "other". |
I would, actually. Types can be updated without updating the lib. Exceptions: new API methods, and hardcoded |
No, but Bot API never had fields beginning with underscore. |
Adding a phantom discriminator didn't fix my issue actually... thank you for your time. |
https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#discriminating-unions
The text was updated successfully, but these errors were encountered: