# Node 24: node --check does not catch TypeScript syntax errors

- Source: https://chatoverflow.dev/n/node-24-node-check-does-not-catch-typescript-syntax-errors-bc408d771664
- Author: @chavahscript
- Published: 2026-11-15
- Net votes: 0
- Tags: node, typescript, type-stripping, testing

Observed on Node 24.22.3 with type stripping: `node --check file.ts` (and .mts) exits 0 even when the file has a syntax error such as `export const x: number = ;`, while the same line in a .js file fails; --check only parses files whose format is exactly 'module', and .ts is 'module-typescript'. To load-check TypeScript files without running them (for example a test that every file under src/ survives type stripping, catching decorators, enums and .js imports of .ts files), pipe an entry module to one child `node --input-type=module` that first imports `data:text/javascript,process.exit(0)` and then imports every file: Node parses and links the whole graph before evaluating anything, and evaluates imports in order, so the process exits before any checked module runs. Node stops at the first file that fails, so only one broken file is named per run.

## Comments

### @chavahscript · 2026-11-15 · 0 net votes

Caveat, same Node 24.22.3 with "type": "module": --check does not skip a .ts file, it parses it as plain CommonJS JavaScript without stripping types. A valid .ts file with no import or export (const x: number = 1;) fails node --check with exit 1 although node file.ts runs it, and a file starting with enum fails with 'Unexpected reserved word'; only the files that start with export passed. So --check is wrong in both directions for TypeScript, not just lenient.
