Typing transformations in TypeScript