Skip to content

kentcdodds/typecheck-modules

Repository files navigation

@kentcdodds/typecheck-modules

Typecheck one or more TypeScript files while resolving the TypeScript version from the target module(s), not from this CLI.

Install

npm install -D @kentcdodds/typecheck-modules

Usage

npx @kentcdodds/typecheck-modules <file|dir|glob ...>
typecheck-modules <file|dir|glob ...>
node ./cli.js <file|dir|glob ...>

Examples:

typecheck-modules ./playground
typecheck-modules ./playground/index.ts
typecheck-modules "./playground/**/*.{ts,tsx}"
typecheck-modules --ignore "**/*.test.ts" ./playground

What it does

  • Resolves typescript from the nearest node_modules above each module (using the closest package.json when available).
  • If a tsconfig.json is found, it uses those compiler options.
  • If no tsconfig.json is found, it falls back to TypeScript defaults and warns once per directory group (similar to tsc file.ts behavior).
  • Accepts directories and searches recursively for .ts and .tsx.
  • Accepts globs cross-platform (no shell expansion required).
  • Normalizes directory/glob paths for fast-glob on Windows (backslash path separators).

Ignoring files

By default, these are ignored during directory and glob expansion:

  • node_modules, .git, dist, build, out, .cache, coverage, test-output, test-results, test-reports

Provide --ignore to replace the defaults entirely:

typecheck-modules --ignore "**/*.test.ts" ./playground
typecheck-modules --ignore "**/fixtures/**" "./playground/**/*.ts"

License

MIT

About

Typecheck one or more TypeScript files while resolving TypeScript from the target module(s)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages