migrate-to-typescript — Claude Code command for JS migration
This command guides a JavaScript project through a TypeScript migration, from compiler setup to type fixes. Choose a gradual, complete, strict, or incremental approach.
npx claude-code-templates@latest --command setup/migrate-to-typescriptWhat migrate-to-typescript does
The command inspects package.json, counts .js and .ts files, and looks for a build configuration. It then sets up TypeScript and tsconfig.json, adds type definitions, renames files to .ts or .tsx, and works through compiler errors.
Pass a migration strategy as an argument. The workflow also covers test updates and type checking. Strict mode means addressing type mismatches and null or undefined handling, so account for those fixes when planning the conversion.
What it helps with
- convert JavaScript files to TypeScript
- configure
tsconfig.jsonand build-tool integration - add dependency and custom type definitions
- resolve errors raised by strict type checking
- update tests and type validation
Example prompts for the agent
- Migrate the project gradually from JavaScript to TypeScript:
/migrate-to-typescript --gradual. - Convert the JavaScript codebase to TypeScript:
/migrate-to-typescript --complete. - Use an incremental approach for the migration:
/migrate-to-typescript --incremental.
How to install migrate-to-typescript
1claude-code-templates
npx claude-code-templates@latest --command setup/migrate-to-typescript2Manually: put the files in place
.claude/commands/migrate-to-typescript.mdCall it with /migrate-to-typescript. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/migrate-to-typescript.mdCall it with /prompts:migrate-to-typescript. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/migrate-to-typescript.prompt.mdManually: put the files in place
.gemini/commands/migrate-to-typescript.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about migrate-to-typescript
How do I install migrate-to-typescript in Claude Code?
Run npx claude-code-templates@latest --command setup/migrate-to-typescript. The command file is at .claude/commands/migrate-to-typescript.md.
What does migrate-to-typescript do?
It guides a JavaScript project through TypeScript setup, adding type definitions, renaming files, and resolving compiler errors.
Which migration strategies can I choose?
Pass a gradual, complete, strict, or incremental strategy as the command argument.
Source text
migrate-to-typescript.md · MIT
--- allowed-tools: Read, Write, Edit, Bash argument-hint: "[migration-strategy] | --gradual | --complete | --strict | --incremental" description: Migrate JavaScript project to TypeScript with proper typing and tooling setup --- # Migrate to TypeScript Migrate JavaScript project to TypeScript with comprehensive type safety: **$ARGUMENTS** ## Current JavaScript State - Project structure: @package.json (analyze JS/TS mix and dependencies) - JavaScript files: !`find . -name "*.js" -not -path "./node_modules/*" | wc -l` - Existing TypeScript: !`find . -name "*.ts" -not -path "./node_modules/*" | wc -l` - Build system: @webpack.config.js or @vite.config.js or @rollup.config.js ## Task Systematically migrate JavaScript codebase to TypeScript with proper typing and tooling: **Migration Strategy**: Use $ARGUMENTS to specify gradual migration, complete conversion, strict mode, or incremental approach **Migration Process**: 1. **Environment Setup** - TypeScript installation, tsconfig.json configuration, build tool integration 2. **Type Definitions** - Install @types packages, create custom type declarations, define interfaces 3. **File Migration** - Rename .js to .ts/.tsx, add type annotations, resolve compiler errors 4. **Code Transformation** - Convert classes, functions, and modules with proper typing 5. **Error Resolution** - Fix type mismatches, null/undefined handling, strict mode issues 6. **Testing & Validation** - Update test files, configure type checking, validate type coverage **Advanced Features**: Generic types, mapped types, conditional types, module augmentation, and strict compiler settings. **Developer Experience**: Configure IDE integration, debugging, linting rules, and team onboarding. **Output**: Fully typed TypeScript codebase with strict type checking, comprehensive IntelliSense, and improved developer productivity.
© davila7 · MIT · davila7/claude-code-templates