Refactoring JavaScript to TypeScript with GitLab Duo Workflow

This post details the technical process of using GitLab Duo Workflow to refactor a JavaScript file to TypeScript. It outlines the challenges of JS-to-TS migration, the specific capabilities of Duo Workflow (contextual awareness, multi-stage planning, human-in-the-loop, staged changes), and the underlying AI model (Claude 3.5 Sonnet). The analysis phase identified specific typing needs for store state, workflow objects, and GraphQL responses. The planning phase outlined steps for creating a new TypeScript file, defining interfaces, copying and annotating code, and updating imports. The execution phase involved user approval of the plan and visual progress indicators. The post highlights the shift from suggestion-only assistance to task-oriented programming and the importance of codebase-wide contextual understanding.