WIP: TypeScript errors

This is still a work in progress, but I've been fixing Typescript errors. 13 to go! I'll let you know when this is ready for review.