Windsurf prompt to migrate JavaScript to TypeScript
An incremental JavaScript to TypeScript migration that never leaves the build broken: allowJs first, leaf modules converted in dependency order, and tsc plus the tests run after every directory. Windsurf keeps the loop tight because Cascade fixes the errors it just caused while the compiler output is still in front of it.
Last updated
Migrate this repo from JavaScript to TypeScript incrementally. Add tsconfig.json with allowJs and checkJs enabled and strict off, so nothing breaks on day one. Convert in dependency order: leaf utilities, then shared modules, then entry points. Rename one directory at a time; after each directory, run tsc --noEmit and the existing tests in the Windsurf terminal and report the error count before continuing. Never reach for any; prefer unknown plus narrowing, and give every exported function an explicit signature. Wrap untyped third-party modules behind typed shims in src/types/. When the tree compiles, flip strict on and list which strict flags still fail, grouped by directory, so I can decide the cleanup order.
Same task in other tools
Questions about this prompt
Will Cascade try to convert the whole repo in one shot?
It will if you let it, which is exactly what the directory-at-a-time instruction prevents. Smaller conversion units keep tsc output readable and make it obvious which rename introduced which errors.
How do I adapt this for a monorepo?
Run the prompt per package, starting with the package others depend on, and add project references as you go. Ask Cascade to map the internal dependency order first so upstream code converts before downstream.
tsc passes but the app breaks at runtime. Why?
Usually a JS file did dynamic property access or module mutation that the new types paper over. Search the diff for any, which the prompt does forbid, and give as casts the same scrutiny even though the prompt does not ban them; a cast is the usual way untyped behavior slips past tsc.