I'm developing a small typescript app and stuck in value assigning.
Here are interfaces.
export interface SearchTexts {
SearchText: SearchText[];
}
export interface SearchText {
Value: string;
BusinessID: string;
}
Assign values like this.
let serchTextArr: SearchText[] = [];
const invoiceNos: string[] = ["INV4587965", "INV4589654"];
for (var idx in invoiceNos) {
let searchText: SearchText = {
Value: invoiceNos[idx],
BusinessID: "BSD458"
};
serchTextArr.push(searchText);
}
let searchTexts: SearchTexts;
searchTexts.SearchText = serchTextArr; //Getting error when assigning
Below is the error
(node:17661) UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'SearchText' of undefined
I used console.log for displaying whether the serchTextArr doesn't have values or not. But it has values and still cant figure out the issue. Can anyone tell me where the issue is?