Question presented to candidate:
"Some older Vue 3 code uses let count = $ref(0) with no .value. What was that feature, why did the Vue team remove it, and what happens if that code meets Vue 3.4 or later?"
What a strong answer should cover:
- Reactivity Transform was an experimental, opt-in compile-time transform:
$ref,$computed,$shallowRefand friends declared "reactive variables" that the compiler rewrote toref()plus.value;$()destructured refs and$$()escaped back to the raw ref. - History: shipped experimentally in 3.2.0 (Aug 2021), dropped by the team in Feb 2023, deprecated in 3.3.0 (May 2023), removed in 3.4.0 (Dec 2023). Removal in a minor was allowed because the feature was experimental.
- Reasons: without
.valueit is harder to see what is reactive and what triggers effects; it behaved differently inside and outside SFCs; refs were still needed at function boundaries ($$()), adding a concept; and it risked splitting the ecosystem into two dialects. - On 3.4+ the macros are just undeclared identifiers: the SFC still compiles, then fails at runtime with
ReferenceError: $ref is not defined; type-checking reportsCannot find name '$ref'. - Options: migrate to plain
ref/computedwith.value, or keep the syntax via the Vue Macros plugin. Reactive props destructure is the one piece that survived, stable since 3.5.
Clarifying questions expected:
- "Is this a codebase that is still on 3.3, or one that already upgraded and is broken?"
- "Do you want the migration path, or the design reasoning?"
Code / implementation expected: Optional β the same counter written with $ref and with ref, and what the compiler does with each.