TypeScript rewrite