Trying to access a property of dict with dot notation makes Typescript complain. The language specification, 4.10, states:
ObjExpr [ IndexExpr]
... if ObjExpr ’s apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of the type of that index signature.
I am using:
interface MapStringToFunction {
[index: string]: Function;
}
var dict: MapStringToFunction = {};
dict.say = () => 'hi';
dict.say();
MapStringToFunction has a sting index signature and say is of type String, so it should be allowed? But it obvious is not. What is my mistake and how can I change to code so I can type dict and access properties with dot notation?