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;
},
});