Initial TypeScriptification of RuntimeState

Includes some fixes for the other components.

I'm going to add more type information to RS now.