-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Per-property super accessors in async functions. #26707
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
Conversation
Might be worth noting: this change disables the early exit in the esnext & ES2017 transformers, here: It'd be possible to special case further and use a specific visitor when traversing an async method's body. I'm not sure it's worth the complication - any advice? The other thing I'm not 100% clear on is the scope for the |
return __awaiter(this, void 0, void 0, function* () { | ||
const _super = null; | ||
const f = () => { }; | ||
// call with property access | ||
_super_1("x").value.call(this); | ||
_super_x().value.call(this); |
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.
Maybe I'm missing something, but looking at the way _super_x
is defined in line 91 (an object), shouldn't this be
_super_x.value.call(this);
// ^ no parentheses
instead?
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.
4034cf9
to
bce7cfd
Compare
bce7cfd
to
f784d8a
Compare
@rbuckton please take another look. |
Friendly ping. |
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.
Looks good except for a couple of typos in comments.
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.
Minor change needed for tests.
TypeScript must hoist accessors for super properties when converting async method bodies to the `__awaiter` pattern for targets before ES2016. Previously, TypeScript would reify all property accesses into element accesses, i.e. convert the property name into a string parameter and pass it to `super[...]`. That breaks optimizers like Closure Compiler or Uglify in advanced mode, when property renaming is enabled, as it mixes quoted and un-quoted property access (`super['x']` vs just `x` at the declaration site). This change creates a variable `_superProps` that contains accessors for each property accessed on super within the async method. This allows accessing the properties by name (instead of quoted string), which fixes the quoted/unquoted confusion. The change keeps the generic accessor for element access statements to match quoting behaviour. Fixes microsoft#21088.
* rename _super to _superIndex and _superProps to _super. * reinstate early exit for transformers by marking super accesses as esnext/es2017 in `binder.ts`. * adjust comment in `checker.ts` to new emit.
c7e8a99
to
57d922a
Compare
Done, please take another look. |
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 you added a few git submodules under src/ by mistake.
Change-Id: I30af09343446126ba73ed40199ecc3f0ed515b3e
57d922a
to
539c455
Compare
Fixed. Must have been VS Code doing something in my working directory? Odd. |
@rbuckton Does it look good to you? If so, you can merge, or I will after the weekend. |
Looks good! |
Thanks for the review!
|
TypeScript must hoist accessors for super properties when converting
async method bodies to the
__awaiter
pattern for targets beforeES2016.
Previously, TypeScript would reify all property accesses into element
accesses, i.e. convert the property name into a string parameter and
pass it to
super[...]
. That breaks optimizers like Closure Compiler orUglify in advanced mode, when property renaming is enabled, as it mixes
quoted and un-quoted property access (
super['x']
vs justx
at thedeclaration site).
This change creates a specific accessor for each property access on
super, which fixes the quoted/unquoted confusion. It keeps the generic
accessor for element access statements.
Fixes #21088.