Since I ported esptools over to typescript for this re-write, espressif have released their own version in TS. The one I ported over is still a bit buggy, so it might be better to yeet that code and instead use espressif's code that is more actively maintained.
https://github.com/espressif/esptool-js