Rewriting everythig in TypeScript