Reintroduce type definitions for TypeScript.

- merge into 1 commit (single merge point).