I am currently utilizing Vue.js with Typescript in a webpack project.
Following the guidelines provided in the Recommended Configuration in my tsconfig.json
, I have set:
"strict": true,
Within one of my components, I have:
declare interface Player {
cod: string,
param: string
}
export default Vue.extend({
name: 'basecomponent',
data() {
return {
players: []
};
},
created()
let self = this
axios.get('fetch-data')
.then((response) => {
let res: Players[] = response.data;
for(let i = 0; i < res.length; i++){
self.players.push(res[i]);
}
})
.catch((error: string) => {
console.log(error);
});
},
});
However, when attempting to compile, I encounter the following error:
error TS2345: Argument of type 'Player' is not assignable to parameter of type 'never'.
I suspect that players: []
has the type never[]
.
My inquiry is: How can I determine the types for Vue data object properties?