Skip to content

capture thisArg of optionalChaining in parens - #35494

Merged
Ron Buckton (rbuckton) merged 1 commit into
microsoft:masterfrom
ajafff:call-paren-optionalchain
Mar 4, 2021
Merged

capture thisArg of optionalChaining in parens#35494
Ron Buckton (rbuckton) merged 1 commit into
microsoft:masterfrom
ajafff:call-paren-optionalchain

Conversation

@ajafff

Copy link
Copy Markdown
Contributor

Fixes: #35476

Ron Buckton (@rbuckton) for review

//// [parentheses.js]
var _a;
(o1)(o1 !== null && o1 !== void 0 ? o1 : 1);
(o2 === null || o2 === void 0 ? void 0 : o2.b).call(o2, o1 !== null && o1 !== void 0 ? o1 : 1);

@jridgewell Justin Ridgewell (jridgewell) Dec 6, 2019

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this doesn’t need a .call:

o2 === null || o2 === void 0 ? void 0 : o2.b(o1 ?? 1);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that wouldn't throw an error if o2 is nullish.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, it's wrapped in parens. Never mind, forgot that made the call non-optional.

@rbuckton

Copy link
Copy Markdown
Contributor

Klaus Meinhardt (@ajafff) can you update this PR? Optional chaining has moved from esnext.ts to es2020.ts and the factory function calls need to be updated to use factory. to use the new NodeFactory API.

@rbuckton

Copy link
Copy Markdown
Contributor

I've gone ahead and made the necessary updates. Once CI passes I will merge.

@rbuckton
Ron Buckton (rbuckton) merged commit 15e69ac into microsoft:master Mar 4, 2021
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Optional Chaining does not propagate receiver when parenthesized

4 participants