Course contentsShow
← TypeScript
Lesson 1268 of 1,79629. The Build PipelineFree lesson

Type-Checking vs Building in CI

Separating type-checking from build steps: when to run them together versus in parallel for faster feedback.

Type-Checking vs Building in CI

What you'll learn: How to decide whether to run type-checking and building together or separately in your CI pipeline for faster, more efficient feedback.

In continuous integration, you have two main TypeScript tasks: type-checking (validating types with tsc --noEmit) and building (producing output files, often with bundlers). The question is: should you run them together or in parallel?

Running Them Together (Sequential)

The simplest approach is running type-checking first, then building:

# Sequential approach
- name: Type check
  run: npm run type-check  # tsc --noEmit
- name: Build
  run: npm run build       # bundler build

Pros:

  • Fails fast on type errors before wasting time building
  • Simple mental model
  • Guarantees type safety before any output

Cons:

  • Slower total pipeline time
  • Duplicates some work if your bundler also does type-checking

Running Them in Parallel

For faster feedback, run both jobs simultaneously:

jobs:
  type-check:
    runs-on: ubuntu-latest
    steps:
      - run: npm run type-check
  
  build:
    runs-on: ubuntu-latest
    steps:
      - run: npm run build

Pros:

  • Faster overall pipeline (parallelism)
  • Get type errors and build errors at the same time
  • Better resource utilization

Cons:

  • Might waste build resources if types fail
  • More complex CI configuration
  • Could deploy broken code if you're not careful with job dependencies

The Hybrid Strategy

Many teams use a hybrid: parallel type-checking and building, but only deploy if both succeed:

jobs:
  checks:
    strategy:
      matrix:
        task: [type-check, build]
    runs-on: ubuntu-latest
    steps:
      - run: npm run ${{ matrix.task }}
  
  deploy:
    needs: checks
    runs-on: ubuntu-latest
    steps:
      - run: npm run deploy

This gives you speed and safety.

Key takeaway: Run type-checking and building in parallel for faster feedback when both need to happen, but make deployment depend on both passing. For simple projects, sequential is fine and easier to understand.