I have created an interface
in a TypeScript definition file named d.ts
:
declare module myModule
{
interface IQedModel {
field: string | string[];
operator: string;
}
}
In an Angular controller, I have utilized this interface like so:
vm.filters = <myModule.IQedModel>{
operator: 'and',
field: []
};
function populateFields() {
vm.filters.field = [];
angular.forEach(addedFilters, item => {
vm.filters.field.push(item.data); //<-- THIS LINE SHOWS ERRORS
});
}
An error is being thrown which states:
Property 'push' does not exist on type 'string | string[]'
What do you think is causing this issue?