Convert JavaScript Codebase to TypeScript

Incrementally migrate an entire JavaScript project to TypeScript.

0

Prompt

A safe, incremental approach to converting a JavaScript codebase to TypeScript without breaking production.

## Steps:

1. Install TypeScript: npm install -D typescript @types/node @types/react (adjust for your stack)

2. Initialize tsconfig.json with allowJs: true and checkJs: false for gradual migration.

3. Start with utility files: rename .js to .ts and add type annotations.

4. Ask Copilot: 'Add TypeScript types to this module' for each file.

5. Enable strict type checking file-by-file using //@ts-check comments.

6. Convert React components: add prop types as interfaces, migrate to .tsx.

7. Update build tools (Webpack/Vite/Next.js) to handle .ts/.tsx files.

8. Gradually tighten tsconfig.json (noImplicitAny, strict mode) as coverage improves.

9. Remove allowJs once all files are migrated.

10. Run type checking in CI to prevent regressions.

Related Prompts

View all →