Vue.js comes with official TypeScript type definitions that are installed along the library with NPM.
I am trying to use them to type check a simple app. All of the samples I've found demonstrate the use of TypeScript in components but I couldn't find a way to type check a simple app like:
import * as Vue from 'vue';
interface Item {
name: string;
}
var app = new Vue({
el: '#app',
data: {
items: <Item[]> []
},
methods: {
addItem: function () {
this.items.push({ name: 'Item' });
}
}
});
I guess that the main challenge is that all the data, methods, computed properties, etc., should all be available on this. However in this case, this is of type Vue and does not contain an items property.
Is there a way to pull this off?