I had the same problem but with exporting a component.
Some vs code snippets create templates without necessary types like this below
export default {
data() {
return {
x: "something",
};
},
methods: {
rename(name: string) {
this.x = name;
},
},
};
The problem was I did not add defineComponent()
to export default. So should be
import { defineComponent } from "vue";
export default defineComponent({
data() {
return {
x: "something",
};
},
methods: {
rename(name: string) {
this.x = name;
},
},
});
Make sure you are exporting the component with the defineComponent()
function.