Error In Declare Multiple Dimensional Array In TypeScript
In my app, I need to define an element like: commandsList:[RegExp, string, string]; but when I tried to push the array elements into it, as below: public registerCommand(command:R
Solution 1:
Correct me if I'm wrong, but it looks like you're trying to push an object, where the array expects a RegExp | string
type.
Solution 2:
I found the best way is to use interface
like:
interface ICommand {
regexp: RegExp;
callback: Function;
}
then defining the array as:
let commandsList: ICommand[];
Post a Comment for "Error In Declare Multiple Dimensional Array In TypeScript"