-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
?=
violates the type safety of await
#39
Comments
We will not use the I just need more spare time to be able to rewrite it :) |
Also, why this example would throw TypeError? const n2 ?= await get4Promise(); // TypeError! get4Promise[Symbol.result] is not a function!
|
@arthurfiorette Because the proposal said specifically that async functions would define Symbol.result. It did not say that all functions would define Symbol.result. Since |
The
await
operator was designed to be type safe. That is, theawait
operator can operate on values of any type. When given a value that is not asynchronous, it returns its operand unchanged. For example, given the following:The following variables will all have the value of
4
:However, this does not work with the
?=
polyfill:Even though all of these work with regular assignment, four of them throw a TypeError when used with "safe" assignment. Note of particular concern that the extra parentheses in n3, which are redundant with normal assignment, are now required with safe assignment!
The text was updated successfully, but these errors were encountered: