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

[Reactivity Transform] $$ breaks the original semantics #6312

Closed
sxzz opened this issue Jul 19, 2022 · 3 comments
Closed

[Reactivity Transform] $$ breaks the original semantics #6312

sxzz opened this issue Jul 19, 2022 · 3 comments
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: reactivityTransform

Comments

@sxzz
Copy link
Member

sxzz commented Jul 19, 2022

Vue version

v3.2.37

Link to minimal reproduction

https://sfc.vuejs.org/#eNo9TjsOwjAMvUpkdQAJErFWoRIbh8hSKpe2aj6yXRiq3p2kICb7ffz8VrilpF8LQg2WOxqTKEZZUuOCC10MLIrUVVWE/eFydKGqDpSHNV/zbrOCPs2tYEZK2eHS3HGeozV5K9a/DCcYfYokZ98mPXEM+e1ajtxPYAe12pnC5V4FOxhEEtfGcN+VshPrSE+TN01LkNGjRvbnB8U3I+VgByVic2GD7QP4UU0C

Steps to reproduce

Open the reproduction link, there's an error on SFC playground. Cannot access 'r' before initialization

The code

const r = $ref(1)
$$(r)

is transformed to

const r = _ref(1)
(r)

We can see that $$ is removed, and only brackets remain. It will break the original semantics.
It's actually only one line code: const r = _ref(1)(r).

What is expected?

const r = _ref(1)
r

// ⬇️ formatted to
const r = _ref(1);
r;

What is actually happening?

const r = _ref(1)
(r)

// ⬇️ formatted to
const r = _ref(1)(r);

System Info

N/A

Any additional comments?

IMHO, the brackets should be removed to avoid changing the semantics when using $$ function.

@taye
Copy link

taye commented Jan 12, 2023

I've closed my PR. If you decide the best solution is to remove the brackets when transforming $$, I can try to make a PR for that and include the tests from my previous PR.

@sxzz
Copy link
Member Author

sxzz commented Jan 26, 2023

Unfortunately, Reactivity Transform has been dropped officially now, so I closed this issue/PR. If you want to keep using it, please consider the community version Vue Macros.

@sxzz sxzz closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2023
chrislone pushed a commit to chrislone/core that referenced this issue Feb 4, 2023
zhangzhonghe pushed a commit to zhangzhonghe/core that referenced this issue Apr 12, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: reactivityTransform
Projects
None yet
3 participants