A strongly typed finite state machine for TypeScript