npx skills add ...
npx skills add sentimony/skills --skill typescript
You MUST use this when configuring tsconfig, resolving compiler errors, debugging slow type-checking, fixing module resolution or ESM/CJS issues, hardening strictness, migrating JavaScript or a new compiler major, or setting up type-checking in monorepos. Not for general feature work in TypeScript code.
npx skills add sentimony/skills --skill typescript
Use this skill to configure, diagnose, and fix TypeScript projects. It is a workflow, not a language reference: the type system syntax is assumed knowledge, and the focus is on compiler behavior, configuration, and cryptic failures.
Helper Scripts Available:
scripts/inspect_typescript.py - Detects package manager, TypeScript installation source and normalized version, a side-by-side native compiler (TypeScript 7 alias), per-config effective flags, framework checker (vue-tsc, nuxi, svelte-check, astro), uncovered-file counts per category, exact Nuxt coverage counts, monorepo markers, linter, runner, and the recommended typecheck commandscripts/run_typecheck.py - Runs the project's typecheck script or an existing local compiler and summarizes errors by codescripts/trace_perf.py - Measures compilation via --extendedDiagnostics, flags anomalies, optionally writes a compiler trace<skill> means the path to this local skill folder. Run helper scripts with --help when usage is unclear or before first use in a session. Prefer using helper scripts as black-box tools. Read or modify their source only when debugging the skill itself or when behavior is unclear. In a git worktree, resolve <skill> to the skill's absolute path: a relative .agents/skills/... (or .claude/skills/...) path may be gitignored and absent from the worktree checkout.
The helper scripts pay off in monorepos and extends chains; on a small project with one tsconfig, reading the config and running the checker directly is faster.
module/moduleResolution pair, its extends chain, and its package manager. Do not switch resolution strategies to silence one error.run_typecheck.py --project <pkg tsconfig> or --files before a full-repo check.any, as, or @ts-ignore to get to green. Reaching for them means the actual cause is not yet understood; find it first, and use targeted narrowing or a documented @ts-expect-error only as a last resort. One pragmatic exception: casts at test mock boundaries (mock as unknown as Service) are acceptable in test files; production code is not.Direction for new or hardened configs (adopt, do not paste wholesale):
strict: true is the baseline; add noUncheckedIndexedAccess and noImplicitOverride when the codebase can absorb them.module/moduleResolution: NodeNext for Node libraries and servers, ESNext/bundler for bundled apps. These two options must be chosen as a pair; see references/module-resolution.md.skipLibCheck: true is a pragmatic default; remove it only when debugging a broken dependency's types.node_modules/typescript/package.json; dependency ranges and global tsc can describe a different compiler. For TypeScript 7, follow references/typescript-7-migration.md.noUnusedLocals/noUnusedParameters (cheap) -> noFallthroughCasesInSwitch/noImplicitOverride (near-free) -> exactOptionalPropertyTypes -> noUncheckedIndexedAccess (most expensive, last).Plain tsc --noEmit silently ignores .vue/.svelte/.astro component files; a green run proves nothing there. Use the framework's checker:
| Stack | Typecheck command |
|---|---|
| Vue SFC | vue-tsc --noEmit |
| Nuxt | project typecheck script or local node_modules/.bin/nuxi typecheck |
| Svelte / SvelteKit | svelte-check |
| Astro | astro check |
Framework-generated tsconfig (Nuxt .nuxt/tsconfig.*, SvelteKit .svelte-kit/tsconfig.json, Astro's base): never edit generated files: the effective flags may live there, not in the root config. Set options through the framework config or the root tsconfig that extends the generated one. For Nuxt's four solution programs, use the ownership mapping in references/audit.md; one root option is not automatically a server or shared-program option. If the generated .nuxt configs are absent, ask the user to run the project's documented prepare command and then rerun the audit. Do not run prepare yourself. Template type errors surface as __VLS_ctx.x is possibly 'undefined' (TS18048): the fix is in the SFC template or props; see references/error-playbook.md. A config: any prop on a component that renders several row/config shapes is a Vue-specific smell: type it with generic defineProps (<script setup lang="ts" generic="TRow extends BaseRow">) instead of any.
For "audit the TypeScript setup" or "tighten types" on a project that already checks green:
If the typecheck reports 0 errors and the strict set (strict, noUncheckedIndexedAccess, noImplicitOverride, noUnusedLocals/noUnusedParameters, noFallthroughCasesInSwitch) is already enabled, there is likely nothing to harden: do not hunt for something to break; go straight to the hygiene grep (step 4) and report the setup as healthy.
typescript pinned in devDependencies; a typecheck script in package.json; CI runs it. "Pinned" here means at least a caret major-compatible range (^6.0.3) with a committed lockfile; prefer a tilde minor-compatible range (~6.0.3) or an exact pin (6.0.3) when a compiler patch has broken the build before. In a side-by-side compiler setup, audit every typecheck* script, not just typecheck: match each against the CI workflow and report any (e.g. a native typecheck:ts7) that CI never runs. inspect_typescript.py reports the native compiler and whether each script uses an explicit or default config without copying script bodies or config paths into its report..ts/.tsx/.vue file falls inside some tsconfig's include (inspect_typescript.py reports how many are uncovered, per production/tests/config category): uncovered code is never type-checked. For a Nuxt solution, read the separate production, tests, and config counts: a green production program does not prove test or runner-config coverage.: any, as any, @ts-ignore, @ts-expect-error, and non-null assertions (the postfix x! operator). Prioritize exported/public APIs and component props > server boundaries > internal utilities. Replace assertions with real guards or type predicates; make a prop required instead of optional when every call site passes it. When one class of finding is massive (roughly 30+ occurrences of non-null x!), do not read each one: review a 10-15% sample, extrapolate, and state the sampling in the report.
For a repeat audit use the delta sampling rule in references/audit.md instead of the 10-15% sample.Linter rules (no-explicit-any and friends) are the linter's domain, not this skill's: note them in audit findings, fix them via lint config.
Full catalog with causes and prioritized fixes: references/error-playbook.md.
| Error | First move |
|---|---|
| TS2307 Cannot find module | Check moduleResolution matches how the code is run/bundled; then missing @types or exports map |
| TS2742 The inferred type cannot be named | Export the referenced type explicitly or annotate the declaration's return type |
| TS2589 Type instantiation is excessively deep | Break the recursion: simplify generic constraints, split unions, alias intermediate types |
| Excessive stack depth comparing types | Replace large type intersections with interface extends; limit recursive conditional types |
| TS5101 'baseUrl' is deprecated | Delete baseUrl; rewrite paths relative to the tsconfig ("@/*": ["./src/*"]); ignoreDeprecations often masks exactly this |
| TypeScript 7 rejects a deprecated compiler option | Upgrade through TypeScript 6, remove ignoreDeprecations, and replace the option; see references/typescript-7-migration.md |
| TypeScript 7 reports missing Node/test globals | Set compilerOptions.types explicitly, for example ["node", "jest"]; TypeScript 7 inherits TypeScript 6's empty default |
| A framework checker or tool fails after installing TypeScript 7 | Check its TypeScript peer range and compiler-API dependency; keep TypeScript 6 side by side when the tool has not added TypeScript 7 support |
ERR_PACKAGE_PATH_NOT_EXPORTED for ./lib/tsc (vue-tsc crashes after a TS bump) | vue-tsc/Volar loads typescript/lib/tsc, removed from exports in TypeScript 7; keep typescript on 6.x until vue-tsc declares TypeScript 7 support (see references/typescript-7-migration.md) and put 7 under the @typescript/native alias |
__VLS_ctx.x is possibly 'undefined' (TS18048) | Template error in a Vue SFC: make the prop required or default it, or guard in the template |
| Editor shows errors CLI does not (or reverse) | Compare the TypeScript versions: editor's bundled TS vs workspace node_modules/typescript |
When type-checking or the editor is slow:
For a Nuxt app program the helper runs tsc, which does not parse .vue files: it exits
nonzero and its numbers are lower than the framework checker's. Take the app baseline
from npx vue-tsc --noEmit --extendedDiagnostics -p .nuxt/tsconfig.app.json instead,
and use the helper for the server, shared, and node programs. A root tsconfig.json
that is a solution (files: [] plus references) has no program of its own: pass
--project for each referenced config; zero files with "no anomalies" means nothing was
measured.
Numbers taken with --trace include the cost of tracing itself (instantiations and types
run higher); record the baseline from a run without --trace and compare traced runs only
with traced runs.
Reading the result: check_time dominating total_time points at type-level work, but
a high instantiations count alone is not slow checking and does not name the culprit.
Before rewriting generics, unions, or intersections, run --trace and look at which
files and which structuredTypeRelatedTo pairs carry the time; framework-typed APIs
(a typed $fetch, route helpers) often dominate and are not the project's types to fix.
High files/lines with modest check time means the program is too large: fix
include/exclude, add project references, check that node_modules or generated output
is not being picked up.
Standard remedies in order: precise include/exclude -> skipLibCheck -> incremental -> project references for multi-package repos.
paths aliases fail at runtime: tsconfig paths are compile-time only; the bundler or runtime needs its own alias config. See references/module-resolution.md.@types versions: duplicate @types/node (or react) across the tree; align versions or set compilerOptions.types explicitly..tsbuildinfo (and node_modules/.cache) after config changes that should have changed the output but seemingly did not.require of an ESM-only package or default-import mismatch; see references/module-resolution.md interop table.composite: true and a build step (tsc -b); see references/monorepo.md.run_typecheck.py reports NODE_RUNTIME_MISMATCH when the active Node does not satisfy a concrete .nvmrc or engines.node minimum. Activate the project's runtime and rerun; do not treat it as a compiler failure. NODE_RUNTIME_UNKNOWN means the helper could not compare a concrete requirement.node_modules/.bin/vue-tsc or tsc binary with a fixed argv. It normalizes compiler-reported paths, config labels, and package-derived identity values internally and emits approved enums/statuses plus category counts, never raw compiler/config paths, package values, output, or file lists. If a compiler is unavailable or fails, coverage stays unavailable instead of becoming an exact-looking zero.references/error-playbook.md - Cryptic compiler errors: cause and prioritized fixesreferences/module-resolution.md - module/moduleResolution pairs, ESM/CJS interop, paths, exports mapsreferences/migration.md - Incremental JavaScript-to-TypeScript migrationreferences/typescript-7-migration.md - Compiler migration to TypeScript 7, including TypeScript 6 compatibility and framework constraintsreferences/monorepo.md - Project references, composite builds, workspace typecheck orderreferences/audit.md - Audit recipes: Nuxt generated-program ownership, counting, repeat auditspython <skill>/scripts/trace_perf.py --root .
python <skill>/scripts/trace_perf.py --root . --trace # deeper: compiler trace