Replies: 2 comments 2 replies
-
If you think it's feasible, I will submit a Pull Request. |
Beta Was this translation helpful? Give feedback.
-
Hey @ilxqx, good to hear from you. 😄 Looking at a popular type-checking library, it appears we can keep it as simple as: import { isTagged } from 'radashi'
export function isAsyncFunction(value) {
return isTagged(value, '[object AsyncFunction]')
} What's unfortunate is I don't think TypeScript can reliably differentiate an I think the best practice is to call the function and type-check its result. let result = options.getFoo()
if (isPromise(result)) {
return result.then(processFoo)
}
return processFoo(result) If you have any insight on how |
Beta Was this translation helpful? Give feedback.
-
I think it is possible to add
isAsyncFunction
to determine whether the input value is a true asynchronous function (i.e., a function defined with theasync
keyword, excluding functions that return a Promise). The pseudocode is as follows:Beta Was this translation helpful? Give feedback.
All reactions