- Home
- Skills
- D Oit
- Do Novelist Ai
- Typescript Guardian
typescript-guardian_skill
- TypeScript
0
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill d-oit/do-novelist-ai --skill typescript-guardian- SKILL.md8.6 KB
Overview
This skill enforces TypeScript strict mode, eliminates use of any, and ensures consistent type safety and strict linting across a codebase. It targets compiler and ESLint violations, adds explicit return types, and introduces type narrowing and safer generics. The outcome is zero TypeScript errors, no explicit any types, and full strict-mode compliance.
How this skill works
The skill analyzes the project with tsc --noEmit and lint rules to locate compiler errors, implicit any usages, unchecked index access, and missing return types. It suggests replacements (unknown, specific interfaces, generics, unions, or type predicates), implements type guards and assertion helpers, and updates tsconfig to required strict flags. After remediation it validates by rerunning tsc and CI linting to ensure all checks pass.
When to use it
- TypeScript compiler errors appear after changes
- Production code contains explicit any or any[] types
- Functions lack explicit return type annotations
- Strict mode flags are not fully enabled or enforced
- You need to eliminate runtime errors related to null/undefined or unchecked index access
Best practices
- Enable full strict mode and noUncheckedIndexedAccess in tsconfig.json
- Replace any with unknown, specific interfaces, generics, or unions—not with assertions by default
- Always add explicit return types: Promise<T>, void, or never where appropriate
- Use user-defined type guards and discriminated unions for robust narrowing
- Prefer assertion functions that throw when invariants fail, and keep type assertions minimal
Example use cases
- Fix a build that fails tsc --noEmit by converting implicit any parameters to concrete interfaces
- Harden JSON parsing by returning unknown and applying runtime type guards before use
- Refactor utility functions using any to generic signatures that preserve type information
- Resolve ESLint errors from @typescript-eslint/no-explicit-any by replacing any usages with safer alternatives
- Address runtime crashes from undefined array access by adding guards or optional chaining
FAQ
Changes focus on static typing and safety; most edits add type annotations or guards and do not alter runtime logic. Some fixes add runtime checks (guards/assertions) to prevent errors.
How do you handle third-party libraries without types?
Prefer adding minimal type declaration files in a types/ directory or use well-scoped type assertions with clear justification; avoid broad any usage.