-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Async function support? #22
Comments
I'm not sure how I feel about this. It's easy to add, and I think it's an interesting idea, but how often will users want to know if the function is async versus just a function? If we did add support for this, I think it would need to be optional, or another method. |
Sure, no worries @jonschlinkert, I'll leave it up to you. I can't speak for others but I've run into that situation a few times recently whilst working with observables and partially applied functions. It was helpful to know if I'd definitely be receiving a Promise. |
Ha. Coming here obviously for second time, haha. I'm for adding that too. Probably behind option - Yea, such cases are some rare cases and adding option for this may sounds ugly but.. |
I agree, I've been thinking about this more and it makes sense to expose something for this. I'll try to brew something up. |
This feature is a breaking change, as previously covered in this rejected PR. If some client uses a check like The other issue is, as OP pointed out, this is in fact fragile - because this works: (async function () {})[Symbol.toStringTag] === 'AsyncFunction' // => true But this does not: (function () { return Promise.resolve() })[Symbol.toStringTag] === 'AsyncFunction' // => false In practical terms, if this was implemented, transpilers such as Babel would break your code when it converts an In Javascript terms, there is really no distinction in terms of types - the presence of typeof (async function () {}) // => 'function'
(async function () {}) instanceof Function // => true The type of an One should expect to be able to refactor freely between If there is a case where you needed to know the return-type of a function, the only reliable approach is to call the function first, and then check if the type of the returned value is I don't think this feature belongs in a type-checking library - it already provides the ability to check the returned value from a function (to see if it's a I would vote to close this issue. |
Are there plans to identify async functions?
I've been doing checks with example below but I am sure that it'll be a very fragile approach.
The text was updated successfully, but these errors were encountered: