Skip to content

Type { ... } is not assignable to type 'SomeClass' #1864

@colinblaise

Description

@colinblaise

Using vue-tsc 0.40.13, vue 2.7.9, and using the options api.

I have a class called ActionList that I am assigning in data() like so:

data() {
  return {
    actionList: new ActionList([]),
  }
},
...

Viewing the type when hovering over actionList correctly shows ActionList.

image

However, hovering over this.actionList shows a destructured representation of ActionList (fine, nbd)

image

The problem is that the template is throwing a type error.

image

This error is shown when I set the component's prop definition to either:

props: {
    actionList: {
      type: Object as PropType<ActionList>,
      required: true,
    },
}

or

props: {
    actionList: {
      type: ActionList,
      required: true,
    },

Has anyone experienced similar issues? Perhaps I just need additional configuration.

Note

Doing the following suppresses the error, but vue-tsc complains about this

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions