I use generics when using object literals to help simplify the process of interface building. So, for example, my base interface for all objects that use string as keys is
interface IStringTMap<T> { [s: string]: T; };
If I wanted to use this to enforce an object to be entirely made of functions I'd make a new interface
interface IStringFunctionMap extends IStringTMap<Function> { };
Occasionally, however, I want to use more complex objects. For example, let's say I wanted to build the following structure:
var obj = {
"group_1" : {
"func_1" : function() {},
"func_2" : function() {}
},
"group_2" : {
"func_1" : function() {},
"func_2" : function() {}
}
}
I can build this interface pretty easily from raw bits
interface IFunctionGroups { [s: string]: { [s: string]: Function } };
How would I go about making this more readable using my existing IStringTMap
interface?
I've tried using my caveman logic, but just shoving one interface into another
interface IFunctionGroups extends IStringTMap<IStringFunctionMap>;
Gives me the following error:
An interface an only extend an identifier/qualified-name with optional type arguments.