Subscribe on changes!

ToRefs doesn't respect readonly properties, UnwrapNestedRefs doesn't respect ComputedRef

avatar
Dec 23rd 2021

Version

3.2.26

Reproduction link

jsfiddle.net/qz970sop/

Steps to reproduce


const shouldHaveComputedRef = toRefs(readonly(reactive({ foo: 'foo' })))

// runtime warning, no TS error
shouldHaveComputedRef.foo = 'bar'

const shouldHaveReadonly = reactive({ foo: computed(() => 'foo') })

// runtime warning, no TS error
shouldHaveReadonly.foo = 'bar'

What is expected?

toRefs/reactive return types should include correct readonly/ComputedRef types.

What is actually happening?

toRefs/reactive return types always result in settable property types, even though attempting to set them produces a warning and fails