Skip to content

Type of Readonly Ref changed #4180

@exodusanto

Description

@exodusanto

Version

3.2.0-beta.4

Reproduction link

https://sfc.vuejs.org

Steps to reproduce

const object = ref({ count: 1 });
typeof readonly(object); 

const variable = ref(1);
typeof readonly(variable); 

What is expected?

const object = ref({ count: 1 });
readonly(object); // Ref<DeepReadonly<...>>

const variable = ref(1);
readonly(variable); // Ref<Readonly<number>>

What is actually happening?

const object = ref({ count: 1 });
readonly(object); // DeepReadonly<Ref<...>>

const variable = ref(1);
readonly(variable); // DeepReadonly<Ref<number>>

I'm using the readonly function with a Ref<Object[]>.
In 3.1.5 the result of function call is a Ref<DeepReadonly<Object[]>> and with a simple ref like Ref<string> the result is Ref<Readonly<string>>

Since 3.2.0-beta.1 a primitive type like string the result is no more Ref<Readonly<string>> but DeepReadonly<Ref<string>> and using the ref in a watch context the new / old value seems to be the ref instead of the value changed.
And the object from Ref<DeepReadonly<...>> became DeepReadonly<Ref<...>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions