-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
let promises be unions #10751
Comments
Actually, you can EDIT: well, that's the specified JS behavior, of course. Now the question is: in a typed world, does it make sense or do we want to be more strict and EDIT 2: thinking some more... maybe it should raise a warning if you |
@jods4 I am not sure I understand this statement. JavaScript does not have interfaces. |
@aluanhaddad I meant that JS supports awaiting any value, not only promises/thenable. It is not an error to |
|
@Arnavion Thanks for the link. I see this was beaten to death in several issues already. So I guess we should be able to await anything! I noticed @RyanCavanaugh said in that thread:
But as @Aleksey-Bykov says, the following code trips up the type checker: let x: number | { then(): number };
async function f() {
return await x; // Error
} I think that TS should distribute the |
@jods sorry, it appears I misunderstood the context. Distributing the |
Not sure what you are referring to. By 'distributing' I meant that the expression |
Given that |
nightly build, September 7, 2016
currently in order for async/await to work it has to be a solid interface with a
then
method, await doesn't accept a union that has a callablethen
, please allow unions for promisesThe text was updated successfully, but these errors were encountered: