This skill activates when you're debugging TypeScript/JavaScript build errors, compilation failures, or type mismatches. Provides patterns for common errors, root cause analysis techniques, and fixes for type-related issues across frameworks.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
When builds fail with TypeScript errors or type checking issues, this skill provides structured debugging approaches and common patterns you'll encounter.
Pattern: "Property X does not exist on type Y"
Root causes:
?)Debugging approach:
Common fix:
// ❌ BEFORE: Property missing from interface
interface User {
name: string
email: string
}
const user = {
name: "John",
email: "john@example.com",
avatar: "/avatar.png" // ❌ Not in interface!
}
// ✅ AFTER: Add optional property
interface User {
name: string
email: string
avatar?: string // ✅ Now it matches
}
Prevention: Always update type definitions when adding properties.
Pattern: "Implicit 'any' type"
Root causes:
Debugging approach:
Common fix:
// ❌ BEFORE: Implicit any
function processData(data) {
return data.toUpperCase()
}
// ✅ AFTER: Explicit type
function processData(data: string): string {
return data.toUpperCase()
}
Prevention: Enable noImplicitAny in tsconfig.json.
Pattern: "Type error in JSX/React component"
Root causes:
Debugging approach:
Common fix:
// ❌ BEFORE: Props interface incomplete
interface ButtonProps {
text: string
}
function Button({ text, onClick }: ButtonProps) {
return <button onClick={onClick}>{text}</button>
}
// ✅ AFTER: Add missing prop
interface ButtonProps {
text: string
onClick: () => void
}
function Button({ text, onClick }: ButtonProps) {
return <button onClick={onClick}>{text}</button>
}
Prevention: Keep component props interfaces in sync with actual usage.
Pattern: "This value of type A cannot be assigned to type B | C"
Root causes:
Debugging approach:
Common fix:
// ❌ BEFORE: No type guard
function getValue(value: string | number): string {
return value.toUpperCase() // ❌ number doesn't have toUpperCase
}
// ✅ AFTER: Type guard
function getValue(value: string | number): string {
if (typeof value === 'string') {
return value.toUpperCase()
}
return String(value)
}
Prevention: Always guard union types before using type-specific methods.
Pattern: "Type 'string | null' is not assignable to type 'string[]'"
Root causes:
Debugging approach:
Common fix:
// ❌ BEFORE: Type mismatch
const items: string[] = [
"apple",
"banana",
null // ❌ null not in type
]
// ✅ AFTER: Include null in type
const items: (string | null)[] = [
"apple",
"banana",
null
]
Prevention: Be explicit about optional/nullable array elements.
The error message tells you:
Find the exact line mentioned in the error. Look at:
Find where the type is defined:
Ask:
Common fixes:
npm run build
# or
npx tsc --noEmit
Strict mode catches more errors:
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true
}
}
Benefits:
| Error Code | Meaning | Fix |
|---|---|---|
| TS2322 | Type not assignable | Check type compatibility |
| TS2339 | Property doesn't exist | Add to interface or check name |
| TS2345 | Argument of wrong type | Match function parameter type |
| TS2339 | Implicit 'any' | Add type annotation |
| TS2532 | Object is possibly null | Add null check |
| TS2740 | Missing properties | Add required properties |
Type assertions (as Type) should be rare. Only use when:
// ✅ OK: You control the JSON structure
const data = JSON.parse(json) as UserData
// ❌ Bad: Hiding type error
const value = someUnknownValue as string // Could be null!
Before deployment, verify:
# Full type check
npm run build
# Or just type check (no emit)
npx tsc --noEmit
# With strict settings
npx tsc --strict --noEmit
Catch type errors BEFORE Vercel/CI sees them.