Skip to content

Built with 💚 by Coralogix

tsgo-strict

📖 Docs: tsgo-strict documentation

tsgo-strict is a fast, strict-only TypeScript checker. It drives the native TypeScript compiler shipped in TypeScript 7 or later (the typescript package, formerly the tsgo native preview) and emits only the diagnostics you would see if strict mode were turned on for a specific subset of your project — enabling a file-by-file or path-by-path migration to strict.

Written in Rust and distributed through per-platform npm packages (the tsgo-strict launcher plus one prebuilt binary + N-API addon per target, resolved via optionalDependencies).

Drop-in replacement for typescript-strict-plugin. tsgo-strict reads the same plugins block from your tsconfig.json and honors the same // @ts-strict-ignore pragma, so migrating is usually just swapping tsc-strict for tsgo-strict in your scripts, with no config changes. It replaces the tsc-strict CLI checker (not the editor language-service plugin) and runs ~7.7× faster.

What it does

  • Reads typescript-strict-plugin config from compilerOptions.plugins.
  • Honors @ts-strict / @ts-strict-ignore pragmas.
  • Supports checking an explicit subset of files or globs.
  • Runs tsgo once with "strict": true enabled, scoped to the selected files, and reports the diagnostics it produces.

Why you'd use it

Flipping "strict": true on a large, legacy codebase typically surfaces thousands of errors at once. tsgo-strict lets you enable strict mode only for the files or paths that are ready, so you can migrate incrementally without drowning the build.

You opt files in via one of:

  • A plugin config in tsconfig.json listing the paths (and optional exclude regex) that should be checked strictly.
  • A // @ts-strict comment at the top of a file to force it into scope.
  • A // @ts-strict-ignore comment to force a file out of scope, even if the plugin paths would match it.

Everything else is checked under your normal, non-strict tsconfig settings and its errors are filtered out of the output.

How it works

tsgo-strict:

  1. Loads your tsconfig.json (including extends chains, relative or npm-style like @tsconfig/node20), pulls the plugin block out of compilerOptions.plugins, and computes the project's source file list.
  2. Selects the strict subset. It reads the first 4 KB of each candidate file in parallel, checking for pragmas, then applies the plugin paths / excludePattern filter. Pragmas win over config.
  3. Writes a temporary tsconfig that extends yours with "strict": true enabled and pinned to the selected files.
  4. Spawns tsgo once against that config and collects diagnostics.
  5. Prints the result in tsc-style text, sorted for stable output, with an exit code reflecting whether anything remained.

Configure strict scope

Add the plugin block to your tsconfig.json:

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-strict-plugin",
        "paths": ["./src/strict", "./src/shared"],
        "excludePattern": ["**/*.test.ts"]
      }
    ]
  }
}
  • paths — directory prefixes included in the strict subset. A file is included if its path lives under any entry. Omit for "include everything" and rely on pragmas / excludePattern to scope down.
  • excludePattern — array of minimatch glob patterns (a single string is also accepted). Files matching any pattern are excluded.

Then drop pragmas into individual files to override:

// @ts-strict
export function alreadyReady() { /* forced in */ }

// @ts-strict-ignore
export function notYet() { /* forced out */ }

Install

npm install --save-dev @coralogix/tsgo-strict typescript@^7
# or
pnpm add -D @coralogix/tsgo-strict typescript@^7

tsgo-strict needs a native TypeScript compiler: either TypeScript 7 or later (the typescript package) or @typescript/native-preview if your app stays on TypeScript 5/6. It's an optional peer dependency, so a compatible tsc/tsgo binary on PATH, in a local install, or via the TSGO_BINARY env var works too. When @typescript/native-preview is installed it's preferred over your app's typescript, so keeping your app on an older version is fine.

CLI usage

tsgo-strict [fileOrGlob ...]

Options:

  • -p, --project <path> — tsconfig path (default tsconfig.json)

Exit codes:

  • 0 — no strict diagnostics
  • 1 — strict diagnostics found
  • 2 — tool/config/runtime error

Environment:

  • TSGO_BINARY — explicit path to a tsgo binary (highest-priority resolver)

Programmatic API

import { run } from '@coralogix/tsgo-strict';

const result = await run({
  project: 'tsconfig.json',
  subset: ['src/in-scope'],
});

console.log(result.errorCount, result.diagnostics);

Returns { errorCount, exitCode, diagnostics[], timings[] }. Full type definitions ship with the package.

Development

See CONTRIBUTING.md. The short version:

cargo build --release
cargo test --workspace
pnpm test:node          # builds the N-API addon + runs Node integration tests

Open source project files

License

Licensed under the Apache License, Version 2.0.

Copyright 2026 Coralogix Ltd.

About

tsgo-strict is a fast, strict-only TypeScript checker built on Microsoft’s tsgo compiler (@typescript/native-preview). It reports only the diagnostics that would appear with strict mode enabled, scoped to a specific set of files or paths - making it easy to adopt strict typing incrementally across large codebases.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages