Reputation: 189
I've attempted to look at other similar questions, but most of them appear to be defining arrays instead of objects.
I'm mostly new to Typescript as a whole, and am still trying to wrangle some of the concepts, having both experience in C# and JavaScript.
I'm making an object that is a collection of one or more named functions in an object. Each function accepts an array of strings, or multiple strings, as the following definition:
define function PluginCommand(argv: array, ...args:string[]): number;
Now, how can I assign multiple of these PluginCommand
s to a (preferably) defined object where the key can be any valid string?
Upvotes: 0
Views: 779
Reputation: 36
You should be able to do something like:
interface Foo {
bar: (args: Array<string>) => number;
}
If you want the key to be any string, do:
interface Foo {
[key: string]: (args: Array<string>) => number;
}
Upvotes: 1