Aalexbit-codemod

typescript-strictness-mining

Read-only TypeScript strictness mining (syntax + tsconfig metrics) and an optional migration workflow (tsc gate, safe-fixes, strict enablement, AI cleanup).

miningmetricsmigrationtransformationtypescriptjavascriptstrictnessstricttsconfigmonorepo
Public
1 executions

Run locally

npx codemod typescript-strictness-mining

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

WorkflowModifies source?Purpose
mining (default)No — emits metrics onlyFast syntax + tsconfig scan; optional slow tsc pass
migrationYes — rewrites filestsc 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:

  1. Go to app.codemod.com/insights
  2. Create a dashboard and widget
  3. Set the source to js-ast-grep and select typescript-strictness-mining from 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.json only — not tsconfig.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)

antipatternTypesourceKindfixabilityconfidenceNotes
as_any_castsyntaxsafemediumas any and <any> assertions
explicit_any_annotationsyntaxmanualhigh: any type annotations
non_null_assertionsyntaxsafemediumPostfix !
ts_expect_errorsyntaxsafehigh// @ts-expect-error
ts_ignoresyntaxmanualhigh// @ts-ignore
ts_nochecksyntaxmanualhigh// @ts-nocheck
unsafe_index_accesssyntaxmanuallowOpt-in via includeUnsafeIndexAccess

Config (default mining workflow)

antipatternTypesourceKindfixabilityWhen emitted
config_strict_disabledconfigconfig_onlystrict not enabled
config_partial_strictconfigconfig_onlySome 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)

antipatternTypesourceKindfixabilityTypical suggestedAction
implicit_any_diagnosticcompilermanualmanual_type_annotation
strict_null_checks_diagnosticcompilermanualtighten_null_handling
unknown_or_never_diagnosticcompilermanualreplace_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)

ParameterDefaultWhat it does
includeUnsafeIndexAccessfalseEmit low-confidence unsafe_index_access for dynamic obj[key] — very high volume
includeCompilerFindingsfalseRun slow per-package tsc and emit compiler blockers + strictness-package-readiness

Migration workflow (--workflow migration)

ParameterDefaultWhat 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)
includeTestsfalseWhen true, safe-fix may edit test/spec files
enableStrictIfReadyfalseWhen true, set compilerOptions.strict: true after zero blockers
runAiCleanuptrueFinal AI review pass after deterministic steps

Metrics

strictness-finding

Per-occurrence findings. Cardinality fields: file, line, antipatternType, sourceKind, fixability, suggestedAction, confidence, optional diagnosticCode.

SourceWhen emitted
Syntax scanDefault mining (always)
Config scanDefault mining (always)
Compiler scanMining 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)

  1. Syntax scanas any, !, @ts-*, : any (and optional index access).
  2. Config scan — tsconfig strictness state per package.
  3. Compiler scan (optional, includeCompilerFindings=true) — tsc blockers 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)

  1. Compiler readinesstsc blockers and package readiness rollups (skips or marks packages blocked when a project is too large or tsc fails).
  2. Safe-fix — deterministic edits only when each change passes strict tsc (project-scoped when a tsconfig.json is found) and a syntax check:
    • removes stale // @ts-expect-error together with a paired eslint-disable-next-line @typescript-eslint/ban-ts-comment when present (never @ts-ignore / @ts-nocheck)
    • removes as any / <any> when safe (skips bracket-index casts and (x as any).prop member-access casts)
    • does not auto-remove ! (non-null assertions) — leave those to mining + AI/manual cleanup
  3. Enable strict (optional, enableStrictIfReady=true) — sets strict: true when blockers are zero.
  4. AI cleanup — runs by default (runAiCleanup=true); pass --param runAiCleanup=false for deterministic-only runs.

Migration may read files from disk (--allow-fs).

Examples

bash

Ready to contribute?

Build your own codemod and share it with the community.