Thursday, 15 September 2011

Generic object in Typescript -


I type a dictionary on TypeScript < TValue & gt; is created, but it works as I want, unless I use it as an array instead of an object. This is my dictionary dictionary:

  class dictionary & Lt; TValue & gt; {[Index: string]: TVLue; }  

So I can only use it:

  var instanceOfDictionary: dictionary & lt; String & gt; = ...; Console.log (instanceOfDictionary ["test"]);  

But I would like to experiment like this:

  console.log (instanceOfDictionary.test);  

Is this possible?

Is this possible?

Unless you explicitly add test as a member. then no.


No comments:

Post a Comment