TypeScript / Type Check
Run a type-checker (tsc --noEmit, mypy, pyright, flow) without running tests.
Reference: loha/type-check@v1
Category: test
Runtime: docker.io/library/node:20-alpine (non-root, digest-pinned at Node 20)
License: Apache-2.0
When to use
Use this step alongside run-lint and run-tests for full static + dynamic coverage. Type-checking is intentionally separate from linting because the failure modes are different and the checks parallelize well.
Parameters
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
CHECK_COMMAND | string | npx tsc --noEmit | No | Type-check command to execute. For TypeScript: npx tsc --noEmit, pnpm type-check. For Python: mypy ., pyright. |
WORKING_DIRECTORY | string | . | No | Directory to run in, relative to workspace root. Use for monorepo subdirectories. |
CHECK_IMAGE | string | docker.io/library/node@sha256:fb4cd12c85ee03686f6af5362a0b0d56d50c58a04632e6c0fb8363f609372293 | No | Container image with type-check tool installed. Use node:20-alpine for TS, python:3.12-slim for mypy/pyright. |
FAIL_ON_ERROR | enum: true, false | true | No | Fail the step if type errors are found. |
Workspaces
source(required): bound from pipeline workspacesource
Results
| Result | Description |
|---|---|
CHECK_RESULT | PASS or FAIL |
ERROR_COUNT | Number of type errors found |
How it works
Runs CHECK_COMMAND inside CHECK_IMAGE under WORKING_DIRECTORY. Default is npx tsc --noEmit on node:20-alpine for TypeScript projects. Exit code drives CHECK_RESULT; ERROR_COUNT is best-effort parsed from tsc/mypy/pyright output.
Examples
TypeScript monorepo app
steps:
- name: type-check
uses: loha/type-check@v1
with:
CHECK_COMMAND: 'pnpm type-check'
WORKING_DIRECTORY: 'apps/dashboard'
Python with mypy
steps:
- name: type-check
uses: loha/type-check@v1
with:
CHECK_COMMAND: 'mypy src/ --ignore-missing-imports'
CHECK_IMAGE: 'python:3.12-slim'
Troubleshooting
Problem: tsc: command not found.
Solution: Add typescript as a dev-dependency in your project so the workspace install pulls it in, or use a custom CHECK_IMAGE with TypeScript pre-installed.
Problem: Type errors in node_modules flood the output.
Solution: Add "exclude": ["node_modules"] to your tsconfig.json or pass --skipLibCheck to tsc.