Skip to content

Typescript, how to annotate a non-reactive instance property? #694

@nilptr

Description

@nilptr

In Vue 2, it is common to assign an instance of third part library to a property of this and perform some destroy actions in destroyed hook.

But I get a type error Property 'xxx' does not exist on type 'ComponentPublicInstance<...> when I do this with Vue 3 and Typescript.

How to annotate a non-reactive instance property?

export default defineComponent({
  mounted() {
    // Error: Property 'tooltipInstance' does not exist on type 'ComponentPublicInstance<...>
    this.tooltipInstance = new Tooltip(this.$ref.reference);
  },
  beforeUnmount() {
    this.tooltipInstance?.destroy();
    this.tooltipInstance = null;
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions