Skip to content

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

@Kbitt

Description

@Kbitt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.scope: types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions