Take a look at this simple example
import Vue from "vue";
export default Vue.extend({
props: {
text: String,
},
methods: {
click() {
console.log(this.text); // Property 'text' does not exist on type 'Vue'.Vetur(2339)
},
},
});
However, when I specify the event type, everything works as expected
import Vue from "vue";
export default Vue.extend({
props: {
text: String,
},
methods: {
click(event: MouseEvent) {
console.log(this.text); // Everything is fine now!
},
},
});
But this creates another issue, as I don't actually need to use the event
parameter for my component.
Even though I can write click(_: MouseEvent)
, it makes the code less clear.
How can I avoid having to specify the event type?