fix(transformer/optional-chaining): fix context of optional chain call#9526
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #9526 will not alter performanceComparing Summary
|
7f91270 to
63c1ba7
Compare
this when transforming x.y?.()this when transforming member expressions
...ormance/tests/babel-plugin-transform-optional-chaining/test/fixtures/oxc/keep-this/output.js
Outdated
Show resolved
Hide resolved
...formance/tests/babel-plugin-transform-optional-chaining/test/fixtures/oxc/keep-this/input.ts
Show resolved
Hide resolved
|
Have you compared the output to Babel? The transformer implementation almost port from Babel. |
I tested on babel repl (link) and the output of I updated some conformance snapshots with |
this when transforming member expressions
Dunqing
left a comment
There was a problem hiding this comment.
Great! The optional chaining plugin is very complicated and not easy to debug. Thank you for finding and fixing this bug!
Merge activity
|
#9526) - closes #9498 `this.f?.()` is handled by #9505, but it looks like the same needs to be applied for member expressions in general, such as `repro.x.f?.()`. Here is an output of esbuild https://esbuild.github.io/try/#dAAwLjI1LjAALS10YXJnZXQ9ZXMyMDE1AGNvbnN0IHJlcHJvID0ge30KcmVwcm8uZj8uKCk7CnJlcHJvLnguZj8uKCk7CnJlcHJvLnhbImYiXT8uKCk7 --- This PR fixes following case: - Not only member expressions but also arbitrary expressions can be a call context, such as: ```js (0, repro).f?.(); ``` - same logic is required for `transform_and_join_expression`, which is used in cases, such as ```js repro.x?.y.f?.() ```
6fe8f95 to
cead38d
Compare

thiscontext #9498this.f?.()is handled by #9505, but it looks like the same needs to be applied for member expressions in general, such asrepro.x.f?.().Here is an output of esbuild
https://esbuild.github.io/try/#dAAwLjI1LjAALS10YXJnZXQ9ZXMyMDE1AGNvbnN0IHJlcHJvID0ge30KcmVwcm8uZj8uKCk7CnJlcHJvLnguZj8uKCk7CnJlcHJvLnhbImYiXT8uKCk7
This PR fixes following case:
transform_and_join_expression, which is used in cases, such as