Port Command object to Typescript

Touches a significant part of the frontend code.  Biggest change is
typed events.

Not well tested.