Skip to content
CodeMorph
Learn

Keeping TypeScript green in CI

Add type-checking to continuous integration so a migration can't slip backwards, with a ready-to-use workflow and ways to track type coverage.

Beginner2 min readUpdated 11 October 2026

A migration is only finished if it stays finished. Continuous integration is how you make sure no one reintroduces type errors, untyped JavaScript or any after the work is done.

The three checks

Run the same checks CodeMorph's Verify runs locally:

npx tsc --noEmit
npm test
npm run build

Add a script so everyone runs the same command:

package.json
{
  "scripts": {
    "typecheck": "tsc --noEmit",
    "test": "vitest run",
    "build": "vite build"
  }
}

A GitHub Actions workflow

.github/workflows/ci.yml
name: CI
on:
  pull_request:
  push:
    branches: [main]
 
jobs:
  verify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: npm run typecheck
      - run: npm test
      - run: npm run build

Make the job a required check on your main branch, so a pull request can't merge with type errors.

During the migration

You don't have to wait until the end. Add the typecheck to CI as soon as the first batches merge. With allowJs: true and checkJs: false, only converted files are checked, so CI protects what's done without blocking what isn't.

Stopping JavaScript from coming back

  • Set "allowJs": false in tsconfig.json once every file is converted. New .js files then fail the typecheck.
  • Lint against any with typescript-eslint's no-explicit-any rule, as a warning at first and an error later.

Tracking type coverage

Error count isn't the whole story: code full of any compiles fine. The open-source type-coverage tool reports what share of identifiers have a real type:

npx type-coverage --detail

Run it in CI and fail the build if coverage drops below your current level. Raise the threshold as you improve.

Tightening over time

Raise strictness one flag at a time in a dedicated pull request, fix the new errors, and let CI hold the line. See Turning on strict mode for a good order.

How this fits with CodeMorph

CodeMorph verifies every batch locally with your own scripts, so a batch that passes Run & Verify passes the same checks in CI. CI then makes sure it stays that way.

Let CodeMorph do the heavy lifting.

Download the beta, open a project and see your migration plan in under a minute.