My question is similar to the ones raised in this and this GitHub issue, but unfortunately they were closed without a solution.
I am working with Vue and TypeScript using Vue Class Components.
I need to access a method of my Vue class from inside a watcher defined in the @Component decorator.
While I know how to access data using this.$data
, I'm not sure how to access methods in this context.
Although my code works during runtime, it generates compilation errors and issues in Visual Studio Code ("Property 'clearInfo' does not exist on type 'Vue'.");
@Component({
watch: {
firstMesh(newMesh) {
if (newMesh === undefined) this.clearInfo(1); // this leads to errors
else this.showMeshInfo(newMesh, 1);
},
secondMesh(newMesh) {
if (newMesh === undefined) this.clearInfo(2);
else this.showMeshInfo(newMesh, 2);
},
},
})
export default class Info extends Vue {
clearInfo(whichMesh : number) {
...
}
showMeshInfo(mesh : any, index : number) {
....
}
}