coding-typescript
coding-typescript
Purpose
This skill equips the AI to assist with TypeScript 5.x development, focusing on advanced features like strict mode, generics, decorators, mapped and conditional types, utility types, and tsconfig configuration. Use it to generate, debug, and optimize TypeScript code in real-time.
When to Use
Apply this skill when working on projects requiring type safety, such as web apps with React or Node.js backends. Use it for code reviews, refactoring legacy JavaScript to TypeScript, or implementing complex type logic in strict mode environments. Avoid it for plain JavaScript unless migration is planned.
Key Capabilities
- Enforce strict mode via tsconfig: Set
"strict": truein tsconfig.json to catch errors like implicit any. - Handle generics: Define reusable functions like
function identity<T>(arg: T): T { return arg; }. - Use decorators: Apply class decorators such as
@Componentfrom frameworks like Angular. - Work with mapped types: Create types like
type Partial<T> = { [P in keyof T]?: T[P]; }. - Implement conditional types: Use constructs like
type IsString<T> = T extends string ? true : false;. - Leverage utility types: Apply
Omit<T, K>orPick<T, K>for type manipulation. - Configure tsconfig: Specify options like
"target": "es2022"and"module": "esnext"for builds.
Usage Patterns
To accomplish tasks, invoke this skill by prefixing queries with the skill ID, e.g., "Use coding-typescript to write a generic array filter function." Always include specific TypeScript version details (5.x) in requests. For code generation, provide context like "Generate a TypeScript class with decorators in strict mode." When debugging, supply error messages and code snippets for targeted fixes. Integrate with IDEs by referencing tsconfig paths, e.g., run tsc --project ./tsconfig.json before AI-assisted edits.