Reputation: 3239
I got this code:
blockingFiles: []; //this is on the class
//this is inside a function of the class
this.blockingFiles = [];
this.blockingFiles.push({file: blockingFile, id: fileId});
But I'm getting an error on file
and id
inside the object I push into the array.
Upvotes: 0
Views: 761
Reputation: 4519
When declaring your blockingFiles
as an empty array, you don't really specify the type of the array elements, that why you get the error.
One solution is to define the Interface of your object (the one that contains "file" and "id" keys) and then declare your blockingFiles
variable as an array of that object.
You could do something like this:
interface IBlockingFiles {
file: string; // Replace the type here if it make sense to your code
id: string; // Replace the type here if it make sense to your code
}
blockingFiles: IBlockingFiles[];
Upvotes: 2