How to initialise empty object array in TypeScript?
Code:
let data: [{productID: number, vendorID: number}] = [];
Compilation error:
Type '[]' is not assignable to type '[{productID: number, vendorID: number}]'.
How to initialise empty object array in TypeScript?
Code:
let data: [{productID: number, vendorID: number}] = [];
Compilation error:
Type '[]' is not assignable to type '[{productID: number, vendorID: number}]'.
2
Answers
The format you have written is a tuple with one-element, try this instead:
Alternatively:
defince a type first
Product
then declare an array of that type: