TypeScript
Write type-safe TypeScript with proper narrowing, inference patterns, and strict mode best practices.
Why use this skill?
Enhance your OpenClaw agent with professional TypeScript expertise. Master type narrowing, generics, strict mode, and best practices for robust, error-free code.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/ivangdavila/typescriptWhat This Skill Does
The TypeScript skill provides OpenClaw with the capability to generate, debug, and enforce industrial-grade TypeScript code. It focuses on the principles of type safety, moving away from dangerous patterns like the any type in favor of unknown and robust type narrowing. This skill ensures that your codebase adheres to strict mode, utilizes advanced inference patterns, and maintains proper module boundaries through type-only imports and accurate declaration files.
Installation
To integrate this skill into your environment, run the following command in your terminal:
clawhub install openclaw/skills/skills/ivangdavila/typescript
Use Cases
- Legacy Migration: Transforming untyped JavaScript projects to strictly-typed TypeScript without losing functionality.
- Complex State Management: Designing discriminated unions to model state transitions accurately.
- API Integration: Defining interfaces for external JSON responses and using type predicates to narrow them safely.
- Configuration Management: Utilizing the
satisfiesoperator to validate configuration objects while preserving literal type information for improved IDE autocompletion. - Library Authoring: Creating high-quality declaration files (
.d.ts) that offer excellent developer experience for consumers.
Example Prompts
- "Refactor this function to use discriminated unions instead of checking multiple optional properties; please ensure the switch statement is exhaustive."
- "I am getting an 'any' type error with this API response. Can you show me how to use 'unknown' and a type guard to narrow this safely?"
- "Convert this config object to use the 'satisfies' operator so I keep the literal types for my CSS classes but still ensure it matches the Config interface."
Tips & Limitations
- Avoid 'any': Always treat 'any' as a failure. When unsure, 'unknown' is your best friend.
- Literal Traps: Remember that object properties widen to their base type; always use 'as const' when you need to preserve specific string or number values.
- Narrowing: Standard tools like
filter(Boolean)do not narrow types effectively. Always provide a type predicate (x is T) to maintain safety during array operations. - Module Boundaries: Always use
import typewhen bringing in interfaces or types. This helps your bundler prune unused code and prevents runtime import issues. - Strictness: Keep 'strict' mode enabled in your tsconfig. If you encounter a complex generic that the compiler cannot infer, don't force it with a type assertion; break the logic into smaller, more granular steps where the compiler can see the flow clearly.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-ivangdavila-typescript": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: code-execution
Related Skills
Animations
Create performant web animations with proper accessibility and timing.
Arduino
Develop Arduino projects avoiding common wiring, power, and code pitfalls.
Bulgarian
Write Bulgarian that sounds human. Not formal, not robotic, not AI-generated.
Arabic
Write Arabic that sounds human. Not formal, not robotic, not AI-generated.
Assistant
Manage tasks, communications, and scheduling with proactive and organized support.