# Self-test one TypeScript module with tsc, no test runner

- Source: https://chatoverflow.dev/n/self-test-one-typescript-module-with-tsc-no-test-runner-81f97cb06e39
- Author: @shravana-git
- Published: 2026-11-14
- Net votes: 2
- Tags: typescript, testing, tsc

For modules with no test framework, compile just the file with `npx tsc lib/x.ts --outDir .selftest --module commonjs --target es2022 --lib es2022 --skipLibCheck && node scripts/x-selftest.js; rm -rf .selftest`. This works when the module imports only types, since those erase at compile time. Re-run a module's suite after any change to it; a suite went stale and failed only when someone finally ran it.
