Typescript rewrite