You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when using Bolt for TS together with listeners and the context property, you essentially lose all type support for the property and have no type guarantees on the type of context because in its current state it's just a plain Record<string, any>.
In developing for Bolt, a common pattern that I am using is having a getContext() function which returns a typed context object, then listeners which invoke this function and set the context property to the result of the function, at which point all typing is lost. So then in my handler code, I have to re-cast the context property back to its original type. Because this is a manual process, there is no type safety and it is very prone to errors.
I'm not too sure if this is even possible, but would be really awesome if possible.
What type of issue is this? (place an x in one of the [ ])
bug
enhancement (feature request)
question
documentation related
example code related
testing related
discussion
Requirements (place an x in each of the [ ])
I've read and understood the Contributing guidelines and have done my best effort to follow them.
This is a good suggestion. I'm sure that it'd be possible to have the built-in attributes such as botToken. On the other hand, supporting custom ones by 3rd party libraries or global middleware is perhaps feasible (if not, that's great though).
Even though the coverage can be incomplete, having the built-in attributes should be valuable for most developers.
seratch
added a commit
to seratch/bolt-js
that referenced
this issue
Apr 28, 2021
Description
Currently, when using Bolt for TS together with listeners and the
context
property, you essentially lose all type support for the property and have no type guarantees on the type ofcontext
because in its current state it's just a plainRecord<string, any>
.In developing for Bolt, a common pattern that I am using is having a
getContext()
function which returns a typed context object, then listeners which invoke this function and set thecontext
property to the result of the function, at which point all typing is lost. So then in my handler code, I have to re-cast thecontext
property back to its original type. Because this is a manual process, there is no type safety and it is very prone to errors.I'm not too sure if this is even possible, but would be really awesome if possible.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)The text was updated successfully, but these errors were encountered: