📖 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-strictreads the samepluginsblock from yourtsconfig.jsonand honors the same// @ts-strict-ignorepragma, so migrating is usually just swappingtsc-strictfortsgo-strictin your scripts, with no config changes. It replaces thetsc-strictCLI checker (not the editor language-service plugin) and runs ~7.7× faster.
- Reads
typescript-strict-pluginconfig fromcompilerOptions.plugins. - Honors
@ts-strict/@ts-strict-ignorepragmas. - Supports checking an explicit subset of files or globs.
- Runs
tsgoonce with"strict": trueenabled, scoped to the selected files, and reports the diagnostics it produces.
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.jsonlisting the paths (and optional exclude regex) that should be checked strictly. - A
// @ts-strictcomment at the top of a file to force it into scope. - A
// @ts-strict-ignorecomment 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.
tsgo-strict:
- Loads your
tsconfig.json(includingextendschains, relative or npm-style like@tsconfig/node20), pulls the plugin block out ofcompilerOptions.plugins, and computes the project's source file list. - Selects the strict subset. It reads the first 4 KB of each candidate
file in parallel, checking for pragmas, then applies the plugin
paths/excludePatternfilter. Pragmas win over config. - Writes a temporary tsconfig that
extendsyours with"strict": trueenabled and pinned to the selected files. - Spawns
tsgoonce against that config and collects diagnostics. - Prints the result in
tsc-style text, sorted for stable output, with an exit code reflecting whether anything remained.
Add the plugin block to your tsconfig.json:
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 /excludePatternto 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 */ }npm install --save-dev @coralogix/tsgo-strict typescript@^7
# or
pnpm add -D @coralogix/tsgo-strict typescript@^7tsgo-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.
tsgo-strict [fileOrGlob ...]Options:
-p, --project <path>— tsconfig path (defaulttsconfig.json)
Exit codes:
0— no strict diagnostics1— strict diagnostics found2— tool/config/runtime error
Environment:
TSGO_BINARY— explicit path to atsgobinary (highest-priority resolver)
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.
See CONTRIBUTING.md. The short version:
cargo build --release
cargo test --workspace
pnpm test:node # builds the N-API addon + runs Node integration testsLicensed under the Apache License, Version 2.0.
Copyright 2026 Coralogix Ltd.
{ "compilerOptions": { "plugins": [ { "name": "typescript-strict-plugin", "paths": ["./src/strict", "./src/shared"], "excludePattern": ["**/*.test.ts"] } ] } }