fix typescript in build.js to merge files in the correct order