Agent skill
TypeScript Ecosystem
This skill should be used when the user asks to "write typescript", "typescript config", "tsconfig", "type definition", "generics", "utility types", or works with TypeScript language patterns and configuration. Provides comprehensive TypeScript ecosystem patterns and best practices.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/typescript-ecosystem-motoki317-dotfiles-2
SKILL.md
TypeScript Ecosystem
Core Concepts
- Strict mode: Enable
strict: truefor maximum type safety - Module resolution:
nodenextfor ESM Node.js,bundlerfor Vite/esbuild/webpack - Type narrowing: Use type guards (
typeof,instanceof,in, custom predicates) - Utility types:
Partial,Required,Pick,Omit,Record,Extract,Exclude,ReturnType,Awaited
Recommended tsconfig
Node.js 22 LTS (ES2023):
{
"compilerOptions": {
"target": "ES2023",
"lib": ["ES2023"],
"module": "nodenext",
"moduleResolution": "nodenext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
Key Strict Options
strictNullChecks- null/undefined handled explicitlynoImplicitAny- Error on implicit anynoUncheckedIndexedAccess- Add undefined to index signaturesnoUnusedLocals/Parameters- Error on unused variables
Type Patterns
Conditional Types with infer
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
type ArrayElement<T> = T extends (infer E)[] ? E : never;
Mapped Types with Key Remapping
type Getters<T> = {
[K in keyof T as `get${Capitalize<string & K>}`]: () => T[K];
};
Custom Type Guards
function isCat(pet: Cat | Dog): pet is Cat {
return (pet as Cat).meow !== undefined;
}
Branded Types
type UserId = string & { readonly __brand: unique symbol };
type OrderId = string & { readonly __brand: unique symbol };
satisfies Operator
const config = {
endpoint: "/api",
timeout: 3000,
} satisfies Record<string, string | number>;
// config.endpoint inferred as "/api" (literal), not string
Anti-Patterns
- any abuse: Use
unknownand narrow with type guards - Type assertions: Use type guards instead of excessive
ascasts - Enums: Use
as constobjects instead - Namespaces: Use ES modules
- Barrel overuse: Can hurt tree-shaking
Tools
tsc --noEmit- Type check onlytsx- Run TypeScript directly with esbuild- ESLint flat config with
typescript-eslint - Vitest or Jest for testing
Context7 Reference
Library ID: /microsoft/typescript
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?