Skip to content

toRefs does not return the correct typescript type #232

@lixpng

Description

@lixpng

If a Object type has a value attribute, after I use toRefs(xxx), the typescripte type will incorrect.
eg:

interface IObjectWithValueAttr {
    name: string
    value: string
}

interface IA {
    b: IObjectWithValueAttr
}

const a: IA = {
    b: {
        name: 'Jon',
        value: 'test'
    }
}

const refsA = toRefs(a)

// there will is a error, because refsA.b will be infer to type `Ref<string>`
refsA.b.name = 'Tony'

Is it because the Ref interface only define the value key ?

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