typedef just like C/C++ typedef just like C/C++ typescript typescript

typedef just like C/C++


From version 1.4 Typescript supports type aliases (source, see also this answer):

type MapEventType2Handler = Dictionary<ControlEventType,     Dictionary<number,     (sender: IControl,      eventType: ControlEventType,      order: ControlEventOrder,      data: any) => void >>;


First off thanks for the kind words :).

Your solution is actually optimal.

Long answerTypescript has two Declaration spaces. Types and Variables.

The only way to introduce items into the type declaration space is via a class or an interface ( 0.8.x could use module to introduce a type as well. Its removed from 0.9.x)

Interface will not work since you want the implementation to stay intact (and interface is implementation independent).

Variables will not work since they do not introduce a name in the Type Declaration space. They only introduce a name in the variable declaration space.

e.g.:

class Foo {    }// Valid since a class introduces a Type AND and Variablevar bar = Foo; // Invalid since var introduces only a variable so bar cannot be used as a type// Error: Could not find symbol. Since compiler searched the type declaration space var baz: bar; // Valid for obvious reasons var x: Foo; 

What you want could be done if the language had a macros but for now class+extends is the only approach.