Skip to content

Private fields cause type errors on ref values #591

Closed
@fango256

Description

@fango256

We have a fairly large vue/typescript project that occasionally runs into type issues when working with the composition api. I think it has something to do with private fields going through Ref/UnwrapRef. I think our usage is valid, but we are still getting to grips with it.

In the code below the myArray variable throws up the following error with TS 4.0.5:

import { ref } from "@vue/composition-api";

class MyClass {
  private memberVariable: string = "";
}

const myArray: MyClass = ref(new MyClass()).value;
         ^^ TS2741: Property 'memberVariable' is missing in type '{}' but required in type 'MyClass

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