convert build worker to typescript

I don't even know why I wrote it in regular JavaScript to begin with. TypeScript is masterrace.