Replies: 2 comments
-
@z1haze thanks for reporting this. I think the docs are just confusing here. The lib treats every model function as async, which in turn of course allows to also pass sync methods, as they are resolved within an async context and are thus non-blocking. I created a PR as initial input for further discussion: #347 |
Beta Was this translation helpful? Give feedback.
-
I think it's important to note here that typescript is just a superset of javascript and the documentation is not wrong here. A sync method can absolutely be used, however typescript is doing its job by providing a narrower typed interface on top of javascript. For example, as JS is loosely typed various value types can be provided in place of others, numbers instead of bool; strings instead of numbers, etc. Typescript types don't usually enumerate the fact that the internals of their code could accept I agree it is confusing for a TS developer who is reading the docs to see that the typings don't agree (and we should probably update the docs and say that they should all be Promises so that we can further tighten the implementation later), but ultimately the fix here is trivial, just mark the function |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
According to the docs model methods are supposed to support either sync or async, but in practice when I attempted to, for example, write the
generateRefreshToken
in a synchronous function, typescript errors because it isn'y async. So i peaked into the interface that the source validates against, and all of the methods are written to return a promise.Documentation stating that they can be sync (supposedly)
Source showing it expects it to return a promise
Beta Was this translation helpful? Give feedback.
All reactions