Starting the Migration: allowJs and checkJs
Enable TypeScript checking in a JavaScript project.
The Migration Challenge
Migrating a large JavaScript codebase to TypeScript all at once is risky. The incremental path: enable TypeScript gradually, file by file, while keeping the project functional.
# Key compiler flags for gradual migration:
# allowJs — allow .js files in the compilation
# checkJs — type-check .js files with JSDoc typesStep 1: Install TypeScript
Add TypeScript to the project and create a minimal tsconfig without strict mode initially.
npm install --save-dev typescript
npx tsc --init
# Edit tsconfig.json to set allowJs: trueAll lessons in this course
- Starting the Migration: allowJs and checkJs
- JSDoc Type Annotations as a Bridge
- File-by-File Conversion Strategy
- Dealing with Untyped Third-Party Libraries