move changed JavaScript to TypeScript