Back in the day I did an almost-Typescript (though much closer than assembly script) to embedded ARM compiler. Some of the techniques may be useful.
https://www.microsoft.com/en-us/research/uploads/prod/2019/0...
https://www.microsoft.com/en-us/research/uploads/prod/2019/0...