franky47/dotfiles/typescript-advanced-types
Claude Code and agent skill by franky47/dotfiles
- community
Checking that the SKILL.md file is still in the repository.
Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.
Install
npx vskill@latest install franky47/dotfiles/typescript-advanced-typesSKILL.md
The same SKILL.md was published earlier as franky47/dotfiles/typescript-advanced-types.
TypeScript Advanced Types
Comprehensive guidance for mastering TypeScript's advanced type system including generics, conditional types, mapped types, template literal types, and utility types for building robust, type-safe applications.
When to Use This Skill
- Building type-safe libraries or frameworks
- Creating reusable generic components
- Implementing complex type inference logic
- Designing type-safe API clients
- Building form validation systems
- Creating strongly-typed configuration objects
- Implementing type-safe state management
- Migrating JavaScript codebases to TypeScript
Core Concepts
1. Generics
Purpose: Create reusable, type-flexible components while maintaining type safety.
Basic Generic Function:
function identity<T>(value: T): T { return value; }
const num = identity<number>(42); const str = identity<string>("hello"); const auto = identity(true); // Type inferred: boolean
Note: using a single letter for trivial generics can be OK, but prefer giving generic arguments a relevant short name instead.
Generic Constraints:
type HasLength = { length: number; }
function logLength<T extends HasLength>(item: T): T { console.log(item.length); return item; }
Multiple Type Parameters:
function merge<T, U>(obj1: T, obj2: U): T & U { return { ...obj1, ...obj2 }; }
2. Conditional Types
type IsString<T> = T extends string ? true : false; type ReturnType<Fn> = Fn extends (...args: any[]) => infer Return ? Return : never; type ToArray<Item> = Item extends any ? Item[] : never;
3. Mapped Types
type Readonly<T> = { readonly [P in keyof T]: T[P] }; type Partial<T> = { [P in keyof T]?: T[P] }; type Getters<T> = { [K in keyof T as get${Capitalize<string & K>}]: () => T[K] }; type PickByType<T, U> = { [K in keyof T as T[K] extends U ? K : never]: T[K] };
4. Template Literal Types
type EventName = "click" | "focus" | "blur"; type EventHandler = on${Capitalize<EventName>};
5. Utility Types
Partial<T>, Required<T>, Readonly<T>, Pick<T, K>, Omit<T, K>, Exclude<T, U>, Extract<T, U>, NonNullable<T>, Record<K, T>
Advanced Patterns
- Type-Safe Event Emitter
- Type-Safe API Client
- Builder Pattern with Type Safety
- Deep Readonly/Partial
- Type-Safe Form Validation
- Discriminated Unions
Type Inference Techniques
inferkeyword for extracting types- Type guards with
value is Type - Assertion functions with
asserts value is Type
Strict mode
In tsconfig.json, strict mode should always be enabled. The following flags should also be on:
- "noFallthroughCasesInSwitch": true
- "noUncheckedIndexedAccess": true
- "noPropertyAccessFromIndexSignature": true
Don't type-cast catch (err: unknown) {}, err is already unknown in strict mode: catch (err) {}.
Best Practices
- Use
unknownoverany - Use
typeoverinterfacefor object shapes - Use
interfacefor declaration-mergeable types (extensible in userland) - Leverage type inference
- Create helper types for reuse
- Use const assertions
- Avoid type assertions — use type guards
- Use tsconfig strict settings eagerly
- Document complex types
- Use strict mode
- Test your types
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdot-claude/skills/typescript-advanced-types/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/franky47/dotfiles/typescript-advanced-types)