I keep getting an error during compilation: error TS2339 Property 'customMethod' does not exist on type 'Action[]'
These are my interfaces:
export interface Action {
Name: string;
someFunc(): void;
}
export interface ActionCollection {
Actions: Action[];
}
Then in my code I'm trying to use a method that has not been described YET in the interface but it is available at runtime. This method is is available from the Actions array within ActionsCollection, just like a native .length property.
let myAC: ActionCollection = new ActionCollection( stuff );
myAC.Actions.customMethod(); // Note that it is attached to Actions
My question is how do I define it in the interfaces?
I've tried something like this, but I got errors:
export interface Action<> {
customMethod(): any;
}
new ActionCollectionasActionCollectionis an interface, you don't get an error there?