core icon indicating copy to clipboard operation
core copied to clipboard

$toRef is not available unless $ref is also used

Open sevein opened this issue 2 years ago • 1 comments

Vue version

3.2.37

Link to minimal reproduction

https://sfc.vuejs.org/#eNo9UNFqwkAQ/JXlKERBk/qapkKpBy1YFZtCH+4l6hojyd1xu9dSQv69l6T1bWdnbm9mWvFkbfzlUaQio6OrLAMhe7tU+mg0MVhnLMEjnPBcadz1aNIqDdBQmcIwAfCPxRTe2VW6nI2roC98zSlEb0hUlAiVhgIOhrnGaBB1SndTpZVOEljJtcwl5C8SNvIzh/XrRsJkvbifQr6Fvdztt6uPZxkP4tGZ157wFKzdOTxPtK/r6UN/bWSDvZ5isw/kEGIGUVhG4ccsGaOGkAEwNrYuGAMCyC6LZdsOr7suSwLq5TeJmImqscbxvClsfCWjQ3FDCeqPICVutSgRmu2xEhdmS2mS0PnY132l2LgyCVPsvOaqwRipmR+c+SZ04bAS/w2J7hcdw4ut

Steps to reproduce

  1. Write a new component that makes use of $toRef but does not use $ref
  2. You'll see the following error: $toRef is not defined

What is expected?

Transform kicks in when $toRef is used.

What is actually happening?

Transformation of $toRef does not happen unless the same file uses $ref.

It does not seem to matter whether $ref is used in a commented line of code.

System Info

No response

Any additional comments?

Related discussion: https://github.com/vuejs/rfcs/discussions/369#discussioncomment-3204419

sevein avatar Jul 25 '22 15:07 sevein

https://github.com/vuejs/core/blob/a95554d35c65e5bfd0bf9d1c5b908ae789345a6d/packages/reactivity-transform/src/reactivityTransform.ts#L29

easy to fix. PR welcome.

edison1105 avatar Jul 27 '22 01:07 edison1105

Maybe this issue has fixed

Hazel-Lin avatar Aug 19 '22 04:08 Hazel-Lin

Maybe this issue has fixed

I don't think so, I've just tested against v3.2.38.

sevein avatar Aug 31 '22 07:08 sevein

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.


This PR has been merged to Vue Macros https://github.com/sxzz/unplugin-vue-macros/commit/8cc7b4cec38034540f7fecae0626965a9b1e7171.

sxzz avatar Jan 26 '23 08:01 sxzz