ts-lint-and-typecheck
Skill0 starsChanged 2 months agoMITView on GitHub
Guides agents through resolving TypeScript compiler errors (TS2322, TS2345, TS2532) and ESLint/Biome violations without suppression comments.
- Installs packages
In this repository49 other files it gives its agents.
- bug-reproducerSkill
- claim-checkerSkill
- command-failure-diagnoserSkill
- config-risk-reviewerSkill
- csv-validatorSkill
- deployment-checklist-makerSkill
- diff-reviewerSkill
- factual-summarizerSkill
- field-extractorSkill
- api-contract-testerSkill
- database-migration-helperSkill
- security-vulnerability-fixerSkill
- git-commit-stagerSkill
- git-conflict-resolverSkill
- github-actions-debuggerSkill
- github-issue-triagerSkill
- github-pr-creatorSkill
- github-pr-reviewerSkill
- go-code-qualitySkill
- go-lint-and-vetSkill
- go-testingSkill
- json-schema-converterSkill
- lint-and-typecheckSkill
- meaning-preserving-editorSkill
- meeting-notes-to-actionsSkill
- minimal-bug-fixSkill
- option-comparatorSkill
- py-code-qualitySkill
- py-lint-and-typecheckSkill
- py-testingSkill
- readme-writerSkill
- regression-test-writerSkill
- release-notes-drafterSkill
- repo-inspectorSkill
- research-briefSkill
- reversible-cleanup-plannerSkill
- rust-clippy-checkSkill
- rust-code-qualitySkill
- rust-testingSkill
- small-refactorSkill
- status-updateSkill
- step-by-step-tutorialSkill
- step-decomposerSkill
- tabular-analyzerSkill
- task-briefSkill
- test-runner-debuggerSkill
- ts-code-qualitySkill
- ts-testingSkill
- skill-templateSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Use this skill when:
- Very specific: line 20
Do not use for Python type checking.
- Very specific: line 21
Do not use for runtime test execution.
- Very specific: line 28
If no file is specified: run npx tsc --noEmit across project to discover failing files.
- Very specific: line 29
Absolute Ban: Never add // @ts-ignore, // @ts-nocheck, or cast to any.
- Very specific: line 30
If property may be undefined (TS2532): add optional chaining (?.) or a defensive guard clause.
- Distinctive: line 33
Follow these numbered actions:
- Very specific: line 48
If a third-party module lacks types: check if npm i -D @types/<package> exists.
- Very specific: line 49
If handling unknown API JSON: define a Zod schema or TypeScript interface.
- Distinctive: line 82
Stop and ask the user when:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
TypeScript Lint and Type-Check
Resolves TypeScript compiler errors and linter violations at the root cause. Enforces strict typing with zero tolerance for @ts-ignore or any.
1. Purpose
Diagnose and solve TypeScript compile errors. "Type Narrowing" refines union types using type guards. "Type Assertion" (as Type) is restricted to verified invariants.
2. When to Use
Use this skill when:
npx tsc --noEmitfails with TS error codes (TS2322,TS2345,TS2532).- ESLint reports
@typescript-eslint/no-explicit-anyorno-unused-vars. - Upgrading TypeScript compiler versions.
3. When Not to Use
- Do not use for Python type checking; use
py-lint-and-typecheck. - Do not use for runtime test execution; use
ts-testing.
4. Required Inputs
target_file: TypeScript file with compiler or lint errors.error_message: Compiler or linter diagnostic output.
5. Missing-Input Behavior
- If no file is specified: run
npx tsc --noEmitacross project to discover failing files. - Absolute Ban: Never add
// @ts-ignore,// @ts-nocheck, or cast toany. - If property may be undefined (
TS2532): add optional chaining (?.) or a defensive guard clause.
6. Procedure
Follow these numbered actions:
- Action 1: Run TypeScript Compiler
- Execute
npx tsc --noEmit. Extract file, line, andTSxxxxcode.
- Execute
- Action 2: Match Error Pattern to Root Cause
TS2322(Type mismatch): Align interface properties or provide default value.TS2532(Object is possibly undefined): Addif (!obj) return ...guard.TS2345(Argument type mismatch): Check parameter types in function signature.
- Action 3: Apply Type-Safe Modification
- Edit the target file cleanly.
- Action 4: Run Linter
- Execute
npx eslint <target_file>ornpx @biomejs/biome check <target_file>.
- Execute
- Action 5: Re-Verify Clean Compile
- Confirm
npx tsc --noEmitexits with code 0.
- Confirm
7. Decision Rules
- If a third-party module lacks types: check if
npm i -D @types/<package>exists. - If handling unknown API JSON: define a Zod schema or TypeScript
interface; do not declare asany.
8. Output Format
Emit the report using this template:
### TypeScript Type-Check Report: [Target File]
- **Compiler Command**: `npx tsc --noEmit` -> PASS
- **Linter Command**: `npx eslint [file]` -> PASS
- **Errors Resolved**: [Count]
#### Resolved Diagnostics
| Line | Error Code | Diagnostic Description | Root Cause Fix |
| :--- | :--- | :--- | :--- |
| `[Line]` | `TS2322` | Type 'null' not assignable to 'string' | Added nullish coalescing default value |
#### Verification Status
- Zero type errors, zero `@ts-ignore` comments.9. Verification Checklist
tsc --noEmitexits code 0.- No
@ts-ignore,@ts-expect-error, oranyadded. - Linter exits code 0.
- Unused variables and imports deleted.
10. Common Failures and Recovery
| Failure Symptom | Cause | Recovery Action |
TS2531: Object is possibly null | Unchecked optional property | Add guard if (item === null) return;. |
@typescript-eslint/no-explicit-any | Using any | Replace with unknown and add type guard. |
11. Stop or Escalation Conditions
Stop and ask the user when:
- Fixing the type error requires breaking public export contracts in a published library.
12. Examples
Example 1: Successful Execution
Input:
File: src/api.ts
Error: TS2532: Object is possibly 'undefined' on line 24: return req.user.id;Output:
### TypeScript Type-Check Report: src/api.ts
- **Compiler Command**: `npx tsc --noEmit` -> PASS
- **Linter Command**: `npx eslint src/api.ts` -> PASS
- **Errors Resolved**: 1
#### Resolved Diagnostics
| Line | Error Code | Diagnostic Description | Root Cause Fix |
| :--- | :--- | :--- | :--- |
| 24 | `TS2532` | Object is possibly 'undefined' | Added guard: `if (!req.user) throw new UnauthorizedError(); return req.user.id;` |
#### Verification Status
- Zero type errors, zero `@ts-ignore` comments.Example 2: Ambiguous or Missing Input
Input:
Fix tsc.Output:
### TypeScript Type-Check Report: Halted - No Errors Provided
- **Status**: Halted
Please provide the compiler error output or run `npx tsc --noEmit` to list active diagnostics.Example 3: Expected Final Output
Output:
### TypeScript Type-Check Report: src/config.ts
- **Compiler Command**: `npx tsc --noEmit` -> PASS
- **Errors Resolved**: 2
#### Resolved Diagnostics
| Line | Error Code | Diagnostic Description | Root Cause Fix |
| :--- | :--- | :--- | :--- |
| 10 | `TS2345` | Argument of type 'string \| undefined' not assignable to 'string' | Validated env variable exists before passing to parser |Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

