Subscribe on changes!

toRef type error - says it unwraps refs but doesn't

avatar
Oct 3rd 2021

Version

3.2.19

Reproduction link

codesandbox.io

Steps to reproduce

  1. Create a shallowReactive object with a deeply nested ref.
  2. Extract a property from it using toRef.
  3. Try to access the nested ref value.

What is expected?

The toRef type is a shallow unwrap, or it actually unwraps the nested ref.

What is actually happening?

The toRef type states the nested ref has been unwraped, when it has not been.


I ran into this issue when I was passing a prop down to a component which mirrors this setup. The props object is equivalent to the shallow reactive object and I wanted to get a ref to my prop, but then typescript started yelling at me.