typescript-strictness-mining
Read-only mining plus an optional migration workflow for TypeScript strictness in any repository layout — monorepos (apps/, packages/, libs/, src/, etc.) or single-package projects.
Registry package: typescript-strictness-mining
| Workflow | Modifies source? | Purpose |
|---|---|---|
mining (default) | No — emits metrics only | Fast syntax + tsconfig scan; optional slow tsc pass |
migration | Yes — rewrites files | tsc gate, conservative safe-fixes, optional strict enablement, AI cleanup (on by default) |
Use mining for dashboards and prioritization. Use migration only when you intend to change code.
Quick start
From your project root:
bash
Use -t /path/to/repo to scan a directory other than the current one. Drop --dry-run when you are ready to apply changes.
Codemod Insights
To visualize findings in a dashboard:
- Go to app.codemod.com/insights
- Create a dashboard and widget
- Set the source to js-ast-grep and select
typescript-strictness-miningfrom the registry
Metrics appear in the run report and in Insights widgets keyed on strictness-finding and strictness-package-readiness.
Scope
The codemod scans from the path you pass with -t:
- Source:
**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}(standard build/output dirs excluded) - Config:
**/tsconfig.jsononly — nottsconfig.app.json,tsconfig.build.json, or other variants
Monorepo layouts such as apps/ / packages/ work out of the box. No Turborepo- or vendor-specific paths are required.
When compilerOptions.strict is fully enabled with no disabled strict flags, config mining emits no finding for that package.
Antipattern reference
Syntax (default mining workflow)
antipatternType | sourceKind | fixability | confidence | Notes |
|---|---|---|---|---|
as_any_cast | syntax | safe | medium | as any and <any> assertions |
explicit_any_annotation | syntax | manual | high | : any type annotations |
non_null_assertion | syntax | safe | medium | Postfix ! |
ts_expect_error | syntax | safe | high | // @ts-expect-error |
ts_ignore | syntax | manual | high | // @ts-ignore |
ts_nocheck | syntax | manual | high | // @ts-nocheck |
unsafe_index_access | syntax | manual | low | Opt-in via includeUnsafeIndexAccess |
Config (default mining workflow)
antipatternType | sourceKind | fixability | When emitted |
|---|---|---|---|
config_strict_disabled | config | config_only | strict not enabled |
config_partial_strict | config | config_only | Some strict flags on, not all |
Config findings are emitted during the config scan only. The compiler readiness step does not duplicate them.
Compiler (opt-in mining or migration workflow)
antipatternType | sourceKind | fixability | Typical suggestedAction |
|---|---|---|---|
implicit_any_diagnostic | compiler | manual | manual_type_annotation |
strict_null_checks_diagnostic | compiler | manual | tighten_null_handling |
unknown_or_never_diagnostic | compiler | manual | replace_unknown_escape |
Parameters
Pass with --param key=value on the CLI, or edit fields in Codemod Insight when running from the UI.
Mining workflow (default)
| Parameter | Default | What it does |
|---|---|---|
includeUnsafeIndexAccess | false | Emit low-confidence unsafe_index_access for dynamic obj[key] — very high volume |
includeCompilerFindings | false | Run slow per-package tsc and emit compiler blockers + strictness-package-readiness |
Migration workflow (--workflow migration)
| Parameter | Default | What it does |
|---|---|---|
targetPackageGlob | '' | Scope transforms to a package path or name glob |
targetTeam | '' | Scope transforms to a team label (package.json owner or first two path segments) |
includeTests | false | When true, safe-fix may edit test/spec files |
enableStrictIfReady | false | When true, set compilerOptions.strict: true after zero blockers |
runAiCleanup | true | Final AI review pass after deterministic steps |
Metrics
strictness-finding
Per-occurrence findings. Cardinality fields: file, line, antipatternType, sourceKind, fixability, suggestedAction, confidence, optional diagnosticCode.
| Source | When emitted |
|---|---|
| Syntax scan | Default mining (always) |
| Config scan | Default mining (always) |
| Compiler scan | Mining with includeCompilerFindings=true, or migration (always) |
strictness-package-readiness
Once per tsconfig.json. Cardinality fields: packageName, packagePath, readiness (ready | blocked), strictState, blockingBucket, optional partialFlags.
Emitted only when the compiler readiness step runs — not on default mining (syntax + config only).
What each workflow does
Mining (default)
- Syntax scan —
as any,!,@ts-*,: any(and optional index access). - Config scan — tsconfig strictness state per package.
- Compiler scan (optional,
includeCompilerFindings=true) —tscblockers and package readiness rollups.
Default mining avoids a full tsc pass on every file for speed. Compiler findings are opt-in or use the migration workflow.
Migration (--workflow migration)
- Compiler readiness —
tscblockers and package readiness rollups (skips or marks packages blocked when a project is too large ortscfails). - Safe-fix — deterministic edits only when each change passes strict
tsc(project-scoped when atsconfig.jsonis found) and a syntax check:- removes stale
// @ts-expect-errortogether with a pairedeslint-disable-next-line @typescript-eslint/ban-ts-commentwhen present (never@ts-ignore/@ts-nocheck) - removes
as any/<any>when safe (skips bracket-index casts and(x as any).propmember-access casts) - does not auto-remove
!(non-null assertions) — leave those to mining + AI/manual cleanup
- removes stale
- Enable strict (optional,
enableStrictIfReady=true) — setsstrict: truewhen blockers are zero. - AI cleanup — runs by default (
runAiCleanup=true); pass--param runAiCleanup=falsefor deterministic-only runs.
Migration may read files from disk (--allow-fs).
Examples
bash