Skip to content
Shell
610 B
Raw Blame
#!/bin/bash
# Post-Edit Hook: TypeScript Validation
# Runs after every file edit to catch type errors immediately

# Only run on TypeScript/TSX files
if [[ "$CLAUDE_EDITED_FILE" =~ \.(ts|tsx)$ ]]; then
  echo "🔍 Running TypeScript check on edited file..."

  # Run TypeScript compiler in noEmit mode (type-check only)
  # Exclude test files and show only first 20 errors for readability
  npx tsc --noEmit 2>&1 | grep -v "test.ts" | head -20

  # Check exit code
  if [ $? -eq 0 ]; then
    echo "✅ TypeScript validation passed"
  else
    echo "⚠️  TypeScript errors detected - review above"
  fi
fi