typescript-strict
Installation
SKILL.md
Your role is to turn on strict type checking and repair the code so the project is genuinely type-safe, without changing runtime behavior or weakening existing verification. Fixing the diagnostics matters; silencing them does not.
1. Establish a baseline first
- Read
package.json(scripts,packageManager,engines), the lockfile(s),.nvmrc/.node-version, and CI config to learn the authoritative package manager, Node version, and build/lint/test commands. - Resolve the declared package manager and workspace first (npm, Yarn incl. PnP, pnpm). Check for the declared compiler without fetching: look for a local
node_modules/.bin/tscor use the manager's local resolution (npm exec --no-install tsc -- -v,yarn tsc -v,pnpm exec tsc -v). Never use bare interactivenpx tscas an availability test: it can offer to install the unrelated npm packagetsc. - If dependencies or the compiler are missing, execute the frozen/immutable restore (
npm ci,yarn install --immutable,pnpm install --frozen-lockfile) before any version, build, lint, or test probe, then confirm the compiler version. A restore failure is a blocker to report separately from compiler diagnostics. Never install anothertsc, and do not switch managers or versions merely to unblock. - Treat a terminal ID, partial output, or prompt as pending, never as passed or completed. Poll the same operation until it finishes and record its exit result. Resolve a blocked terminal before sending dependent checks to it. If you reject a prompt or cancel a command, confirm the shell is usable, run the recovery command immediately, and retry the intended operation; do not end by only promising to.
- Run the project's real build, lint, and test commands before changing anything and record the results, so later failures can be attributed correctly.
- Enumerate every TypeScript config and input:
extendschains,references,tsconfig.*.json(tests, scripts, build, declarations), per-package configs in monorepos, and test runner configs (ts-node/ts-jest/mocha/vitest/jest). Test and secondary configs are in scope, not just the root one.
2. Enable strictness
- Set
"strict": truein each config that type-checks project code (or in the shared base they extend). Do it for test and secondary configs too. - Do not add opt-outs to get green: no
strict: false,noImplicitAny: false,strictNullChecks: false,skipLibCheckadded for convenience, newexcludeentries, narrowerinclude/files,transpileOnly/isolatedModulestest runners, or separate relaxed configs. Preserve original input membership and verification strength. - If the project is large, flags may be enabled incrementally (
noImplicitAny,strictNullChecks,strictFunctionTypes,strictPropertyInitialization,useUnknownInCatchVariables, ...) but the end state must bestrict: true. - This is not a compiler or dependency upgrade. Change tool/dependency versions only if strictness truly requires it (e.g. missing
@types/*), and keep the manifest, lockfile, and package manager in sync.