Hacked together stupidity in typescript