Skip to content
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

Does not transform ||= "logical or assignment" operator #1788

Closed
Tracked by #2228
cspotcode opened this issue Jun 4, 2021 · 1 comment · Fixed by #1811
Closed
Tracked by #2228

Does not transform ||= "logical or assignment" operator #1788

cspotcode opened this issue Jun 4, 2021 · 1 comment · Fixed by #1811
Assignees
Labels
Milestone

Comments

@cspotcode
Copy link
Contributor

Describe the bug

swc does not transform the "logical or assignment" operator (||=)

Input code

I can reproduce this using swc's JS API:

const swc = require('@swc/core');
swc.transformSync(`a ||= b`, {});
swc.transformSync(`a ||= b`, {jsc: {target: 'es5'}});

In both cases the output is:

a ||= b;

Config

N/A

Expected behavior

The ||= operator is transformed into something similar to TS's output.

https://www.typescriptlang.org/play?target=8&ts=4.3.2#code/IYAgPmC8IEYNxA
TypeScript transforms a ||= b into a || (a = b)

Version
The version of @swc/core: 1.2.59

Additional context

@cspotcode cspotcode added the C-bug label Jun 4, 2021
@cspotcode cspotcode changed the title Does not transform ||= logical or assignment operator Does not transform ||= "logical or assignment" operator Jun 4, 2021
@kdy1 kdy1 modified the milestones: v1.2.60, v1.2.61 Jun 5, 2021
@kdy1 kdy1 self-assigned this Jun 11, 2021
@kdy1 kdy1 mentioned this issue Jun 11, 2021
2 tasks
kdy1 added a commit to kdy1/swc that referenced this issue Jun 11, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Jun 11, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Jun 11, 2021
kdy1 added a commit that referenced this issue Jun 11, 2021
swc_ecma_ast:
 - Add `es2021`. 

swc_ecma_transforms_compat:
 - Handle `||=`. (#1788)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 24, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants