Can on__ handler be async?
Seems that having async handlers works fine,
although the particular ESLint config I'm working with doesn't like it,
Are async handlers supported? If so, do Solid's types need to be updated?
7 Replies
Possibly updated the following?
you can use promises
and solid types do not need to be updated
because
void
already means that it doesn’t care about what you return
this seems like an issue with your eslint rule, not typescriptThanks for clarifying. Does
void
really mean that it doesn't care about the return value? Isn't it more like it doesn't expect a return value?yeah you can theoretically return anything and typescript won't complain (which is why an eslint rule might be useful to catch that, as it is weird do do that)
but ts won't let you use the value returned by that function
its a weird design
but it means that any function will extend a
(...a: any[]) => void
typeGot it, thanks!
If the async thing you do is a request, it might be better to just use a signal's setter as event handler and use a derived version of the getter as source for a resource.
We recently enabled
no-misused-promises
and a few more rules around promises to catch places where we did not .catch
(pun intended). It is a very good thing that solidjs has void
here, otherwise this rule would not work properly! Solidjs does NOT catch for you, you should do it yourself!