From act
TypeScript expert guidance for type-level programming, performance optimization, migrations, and real-world problem solving. **PROACTIVE ACTIVATION**: Auto-invoke when working with .ts/.tsx files, encountering type errors, discussing types/generics/interfaces, or configuring TypeScript. **DETECTION**: Check for tsconfig.json, .ts/.tsx files, types/ directory, @types/ packages, or TypeScript-related imports. **USE CASES**: Type errors, generics, tsconfig setup, module resolution, JS→TS migration, type performance, monorepo configuration, declaration files, branded types, conditional types, type testing.
How this skill is triggered — by the user, by Claude, or both
Slash command
/act:typescriptThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- **Vitest**: skill: `vitest` for testing TypeScript code with Vitest framework
vitest for testing TypeScript code with Vitest frameworkrefactor for improving TypeScript code with test coveragetdd for test-driven development workflow in TypeScriptExpert guidance for TypeScript development. This skill uses progressive disclosure - read sections as needed, and dive into reference files when you need deeper coverage.
Analyze the project setup first:
# Core versions
npx tsc --version && node -v
# Check for tooling ecosystem
node -e "const p=require('./package.json');console.log(Object.keys({...p.devDependencies,...p.dependencies}||{}).join('\n'))" 2>/dev/null | grep -E 'biome|eslint|prettier|vitest|jest|turborepo|nx' || echo "No tooling detected"
# Check for monorepo
(test -f pnpm-workspace.yaml || test -f lerna.json || test -f nx.json || test -f turbo.json) && echo "Monorepo detected"
After detection, adapt your approach:
"The inferred type of X cannot be named"
Cause: Missing type export or circular dependency Fix priority:
ReturnType<typeof function> helperexport type { MyType };
export type MyReturnType = ReturnType<typeof myFunction>;
"Excessive stack depth comparing types"
Cause: Circular or deeply recursive types
// Bad: Infinite recursion
type InfiniteArray<T> = T | InfiniteArray<T>[];
// Good: Limited recursion
type NestedArray<T, D extends number = 5> =
D extends 0 ? T : T | NestedArray<T, [-1, 0, 1, 2, 3, 4][D]>[];
Missing type declarations
Read
references/declaration-files.mdfor comprehensive guidance on writing .d.ts files.
// types/ambient.d.ts
declare module 'some-untyped-package' {
const value: unknown;
export default value;
}
"Cannot find module" despite file existing:
moduleResolution matches your bundlerbaseUrl and paths alignmentrm -rf node_modules/.cache .tsbuildinfoPrevent primitive obsession by creating nominal types:
declare const __brand: unique symbol;
type Brand<B> = { [__brand]: B };
export type Branded<T, B> = T & Brand<B>;
type UserId = Branded<string, 'UserId'>;
type OrderId = Branded<string, 'OrderId'>;
function processOrder(orderId: OrderId, userId: UserId) { }
// processOrder(userId, orderId) // Error: Type mismatch
Read
references/type-patterns.mdwhen you need: conditional types, template literal types, mapped types, type inference techniques, or advanced utility patterns.
// Const assertions for literal types
const routes = ['/home', '/about', '/contact'] as const;
type Route = typeof routes[number]; // '/home' | '/about' | '/contact'
// satisfies for constraint validation (TS 5.0+)
const config = {
api: "https://api.example.com",
timeout: 5000
} satisfies Record<string, string | number>;
# Get diagnostics
npx tsc --extendedDiagnostics --incremental false | grep -E "Check time|Files:|Lines:|Nodes:"
# Generate trace for deep analysis
npx tsc --generateTrace trace --incremental false
npx @typescript/analyze-trace trace
skipLibCheck: true (often significant improvement)incremental: true with .tsbuildinfo cacheinclude/exclude preciselycomposite: trueRead
references/performance.mdwhen: type checking is slow, you see "Type instantiation too deep" errors, or you need monorepo performance optimization.
| Use Biome | Use ESLint |
|---|---|
| Speed is critical | Need specific rules/plugins |
| Single tool for lint + format | Complex custom rules |
| TypeScript-first | Vue/Angular projects |
| Fewer rules OK | Type-aware linting needed |
Read
references/tooling.mdwhen: setting up linting/formatting, choosing between Biome/ESLint/Prettier, configuring monorepo tools (Nx vs Turborepo), or migrating between tools.
// avatar.test-d.ts
import { expectTypeOf } from 'vitest'
import type { Avatar } from './avatar'
test('Avatar props are correctly typed', () => {
expectTypeOf<Avatar>().toHaveProperty('size')
expectTypeOf<Avatar['size']>().toEqualTypeOf<'sm' | 'md' | 'lg'>()
})
Run with: vitest --typecheck
Read
references/type-testing.mdwhen: testing library types, using expectTypeOf/assertType APIs, or setting up type test infrastructure.
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"exactOptionalPropertyTypes": true,
"noPropertyAccessFromIndexSignature": true
}
}
"type": "module" in package.json.mts for TypeScript ESM files if needed"moduleResolution": "bundler" for modern toolsconst pkg = await import('cjs-package')# 1. Enable allowJs in tsconfig.json
# 2. Rename files gradually (.js → .ts)
# 3. Add types file by file
# 4. Enable strict mode features one by one
# Helpers
npx ts-migrate migrate . --sources 'src/**/*.js'
npx typesync # Install missing @types packages
| From | To | When | Effort |
|---|---|---|---|
| ESLint + Prettier | Biome | Need speed | Low (1 day) |
| Lerna | Nx/Turborepo | Caching needed | High (1 week) |
| CJS | ESM | Node 18+ | High (varies) |
Nx vs Turborepo:
// Root tsconfig.json
{
"references": [
{ "path": "./packages/core" },
{ "path": "./packages/ui" }
],
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true
}
}
See
references/performance.mdfor monorepo performance optimization.
After changes, validate thoroughly:
npm run -s typecheck || npx tsc --noEmit
npm test -s || npx vitest run --reporter=basic --no-watch
npm run -s build # Only if build affects outputs
Load these files when you need comprehensive coverage:
| File | Read When |
|---|---|
references/type-patterns.md | Building complex types, conditional types, template literals, branded types, inference techniques |
references/performance.md | Slow type checking, "excessive depth" errors, monorepo optimization, compiler diagnostics |
references/type-testing.md | Testing library types, expectTypeOf/assertType APIs, Vitest typecheck setup |
references/declaration-files.md | Writing .d.ts files, module augmentation, ambient declarations, publishing types |
references/tooling.md | Biome/ESLint setup, Nx/Turborepo comparison, migration guides, development tools |
Each reference file includes table of contents, code examples, and troubleshooting guides.
npx claudepluginhub mguinada/ai-coding-toolkit --plugin actProvides advanced TypeScript/JavaScript expertise for type-level programming, performance optimization, monorepo management, migrations, and modern tooling. Analyzes projects, applies fixes, and validates with typechecks/tests.
TypeScript deep-dive skill covering type-level programming, performance optimization, monorepo patterns, and migration strategies. Also redirects to specialized subagents for bundler/module/type issues.
Optimizes TypeScript compilation speed and type complexity with techniques like incremental builds, skipLibCheck, project references, and simplified generics.