C.W.K.
Stream
Lesson 09 of 13 · published

Type checking

~11 min · types, mypy, pyright, tsc

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Lint 가 못 하는 컴파일 타임 gate

Type checking 은 lint 가 못 잡는 버그를 잡아 — 잘못된 타입 인자, 누락된 필드, 처리 안 된 None / null, API contract 불일치. '정적 분석' 과 '시뮬레이션 실행' 사이 경계에서 돔 — 모든 code path 를 머리로 걸어줘서 아빠가 안 해도 돼.

주요 checker

  • Python — mypy: 점진적 타이핑, 원조. PEP 484 타입 힌트 읽음. Strict 모드 권장 (--strict).
  • Python — pyright: Microsoft 의 거. 더 빠름, 더 정확한 추론, VS Code 의 Pylance 동력. ruff 와 함께 자주 사용.
  • TypeScript — tsc: tsc --noEmit 는 출력 없이 type-check 만. 정통 gate.
  • JSDoc 와 JavaScript — 응, JSDoc + // @ts-check 가 transpile 없이 TypeScript checking 의 대부분을 사줘.

CI 의 type checking

  1. 별도 job 으로 (test, lint 와 병렬).
  2. Checker 버전 pin — release 간 type 에러 바뀜.
  3. PR diff annotation 원하면 출력은 사람-읽기 + 기계-읽기 둘 다.
  4. Python 은 production 과 같은 Python 버전에서 실행.

Code

병렬 type-check job (Python + TypeScript)·yaml
  type-check-python:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v3
      - run: uv sync --all-extras --dev
      - run: uv run mypy src --strict --no-incremental

  type-check-typescript:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
        with: { version: 9 }
      - uses: actions/setup-node@v4
        with: { node-version: '22', cache: pnpm }
      - run: pnpm install --frozen-lockfile
      - run: pnpm tsc --noEmit

External links

Exercise

CI workflow 에 strict type-check job 추가. 로컬에서 먼저 한 번 돌려 기존 에러 고치고 push. 이후로 타입은 build 의 일부.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.