-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
await using
normative updates
#16537
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/57425 |
e60eacb
to
2aa75eb
Compare
if (isAwait) { | ||
var inner = dispose; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var inner = isAwait && dispose;
Will this be smaller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- // size: 972, gzip size: 498
+ // size: 971, gzip size: 500
It will save one byte for plaintext but the compressed size is increased by 2.
Could you include tc39/proposal-explicit-resource-management#219 too? |
898b27d
to
631f722
Compare
It seems that the CI failure on Node.js 8 is due to a platform-specific bug. I will skip the new test for Node < 10. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks correct to me, I'll make sure that we are running test262 tests though
if (resource.a) { | ||
return Promise.resolve(disposalResult).then(next, err); | ||
if (!resource.a && state === StateFlag.NEEDS_AWAIT) { | ||
state = StateFlag.NONE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: If tc39/proposal-explicit-resource-management#219 (comment) gets consensus, we can simply change this line to state = StateFlag.HAS_AWAITED
. Before that happens we implement the 2024-06 version as-is.
7a63e72
to
b9602b1
Compare
This PR implements the following normative changes:
Symbol.dispose
method in an await using declaration is ignoredSymbol.dispose
method in an await using declaration are turned into promise rejections.Both of them are supported via a wrapper around the
Symbol.dispose
method.This PR also fixes a compliance issue: When searching a dispose method, Babel will not fallback to
Symbol.dispose
ifSymbol.asyncDispose
method isnull
ordocument.all
.