finished conversion to TypeScript