refactor: begin rewriting in typescript