To declare type in Data declaration in Vuejs, it’s simple. Let’s say you have a Typescript interface Player declared, and you want to use it in one of your Vuejs component. To use it for example in an Array of players, you will do :

data() {
return {
players: [] as Player[]
};
},

You can also declare your Typescript type like this :

data() {
return {
players: new Array<Player>()
};
},

Both will work and give the same results.

For more info on Typescript declaration, check the official documentation for Array type


The Hot Code
© 2025, All Rights Reserved.

Quick Links

Social Media