I would like to have an array containing string error messages. Here is the code I came up with:
var errors: [string];
errors = [];
Object.keys(response.data.modelState).forEach(function (key) {
errors.push.apply(errors, response.data.modelState[key]);
});
I tried several different ways to add typescript definition to variable errors, but none of them work for this case. The first definition works fine, but then when I click the values, I need to click on the array, and when I set:
errors = [];
Then it gives me an error message:
Severity Code Description TS2322 project file line error Type 'undefined []' is not assigned to type '[string]'. The '0' property is missing in the type undefined [] '. Severity Code Description Project file line Build error: Type 'undefined []' is not assigned to type '[string]'.
user1464139