Skip to main content
hooksSource-backedReview first Safety Privacy

TypeScript Checker

Automatically runs TypeScript compiler checks after editing .ts or .tsx files to catch type errors early.

by JSONbored·added 2025-09-19·
HarnessClaude Code
Trigger:PostToolUse
Review first review before installing

Open the source and read safety notes before installing.

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Safety notes
Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.
Privacy notes
Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.
Author
JSONbored
Claim status
unclaimed
Last verified
2025-09-19

Decision playbook

Review trust signals before you adopt

Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.

Compare context
Selected

0

Current score

78

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Complete

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as source-backed.

    Done
  • Metadata reviewed

    Registry metadata indicates a reviewed listing.

    Done

Safety and privacy checks

Complete

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    Review the listed safety guidance before running commands.

    Done
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Needs review

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    No package verification flag provided.

    Pending
  • Checksum metadata

    No checksum provided for downloaded artifact.

    Pending

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

CLI install

Copy-ready — paste the snippet to get started.

Install command

Provided

Config snippet

Provided

Copy snippet

Provided

Prerequisites

None

Platforms

1 listed

Difficulty

0/100

Adoption plan

Balanced adoption plan

Current risk score 16/100. Use staged verification before broader rollout.

Risk 16

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    Listing has review metadata.

    Done
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes are present.

    Done
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    No package verification/checksum metadata.

    Pending

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Required evidence gates are covered (5/6 signals complete).

Risk 15

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Present

Review metadata is present.

Required in this preset

Safety notes

Present

Safety notes are present.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Missing

Package integrity metadata is missing.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required evidence gates are covered for this preset.

Decision timeline

Decision timeline · balanced

5/6 steps complete with no blocking gaps for this preset.

Risk 14

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is available.

Done

verify

Review safety notesRequired

Safety notes are available.

Done

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is missing.

Pending

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

No required blockers for this timeline preset.

Safety & privacy surface

Safety & privacy surface

1 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens, permissions & scopes.

2 areas
  • SafetyPermissions & scopesRuns automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.
  • PrivacyCredentials & tokensReceives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.

Safety notes

  • Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.

Privacy notes

  • Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.

Schema details

Install type
cli
Reading time
5 min
Difficulty score
0
Troubleshooting
Yes
Breaking changes
No
Runtime and command metadata
Trigger
PostToolUse
Script language
bash
Script body
#!/bin/bash

# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')

if [ -z "$FILE_PATH" ]; then
  exit 0
fi

# Check if this is a TypeScript file
if [[ "$FILE_PATH" == *.ts ]] || [[ "$FILE_PATH" == *.tsx ]]; then
    echo "🔍 TypeScript Compilation Checker - Validating TypeScript code..."
    echo "📄 File: $FILE_PATH"
    
    # Check if file exists
    if [ ! -f "$FILE_PATH" ]; then
        echo "⚠️ File not found: $FILE_PATH"
        exit 1
    fi
    
    # Check if TypeScript is available
    if ! command -v npx >/dev/null 2>&1; then
        echo "⚠️ npx not found - please install Node.js"
        exit 1
    fi
    
    if ! npx tsc --version >/dev/null 2>&1; then
        echo "⚠️ TypeScript not found - install with: npm install -g typescript"
        exit 1
    fi
    
    # Get TypeScript version
    TS_VERSION=$(npx tsc --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
    echo "📦 TypeScript version: $TS_VERSION"
    
    # Check for tsconfig.json
    if [ -f "tsconfig.json" ]; then
        echo "⚙️ Using project tsconfig.json"
        CONFIG_FLAG=""
    else
        echo "⚠️ No tsconfig.json found - using default configuration"
        CONFIG_FLAG="--strict --target es2020 --module esnext --moduleResolution node"
    fi
    
    echo "🔍 Running TypeScript compilation check..."
    
    # Run TypeScript compiler in no-emit mode
    if npx tsc --noEmit $CONFIG_FLAG "$FILE_PATH" 2>&1; then
        echo "✅ TypeScript compilation successful - no type errors found"
        
        # Additional file analysis
        echo ""
        echo "📊 File Analysis:"
        
        # Count interfaces, types, classes
        INTERFACES=$(grep -c '^interface\\|^export interface' "$FILE_PATH" 2>/dev/null || echo 0)
        TYPES=$(grep -c '^type\\|^export type' "$FILE_PATH" 2>/dev/null || echo 0)
        CLASSES=$(grep -c '^class\\|^export class' "$FILE_PATH" 2>/dev/null || echo 0)
        FUNCTIONS=$(grep -c '^function\\|^export function' "$FILE_PATH" 2>/dev/null || echo 0)
        
        echo "  • Interfaces: $INTERFACES"
        echo "  • Type aliases: $TYPES"
        echo "  • Classes: $CLASSES"
        echo "  • Functions: $FUNCTIONS"
        
        # Check for any usage
        if grep -q ': any' "$FILE_PATH" 2>/dev/null; then
            ANY_COUNT=$(grep -c ': any' "$FILE_PATH" 2>/dev/null || echo 0)
            echo "  • ⚠️ 'any' types found: $ANY_COUNT (consider more specific types)"
        fi
        
        # Check for strict mode compliance
        if grep -q '"use strict"' "$FILE_PATH" 2>/dev/null; then
            echo "  • ✅ Strict mode enabled"
        fi
        
    else
        echo "❌ TypeScript compilation failed - type errors detected"
        echo ""
        echo "💡 Common fixes:"
        echo "  • Check for missing type annotations"
        echo "  • Verify import statements are correct"
        echo "  • Ensure all variables are properly typed"
        echo "  • Check for undefined/null value handling"
        echo "  • Verify function return types match implementation"
        exit 1
    fi
    
    # Project-wide TypeScript health check
    echo ""
    echo "🏗️ Project TypeScript Health:"
    
    # Count total TypeScript files
    TS_FILES=$(find . -name "*.ts" -o -name "*.tsx" | grep -v node_modules | wc -l)
    echo "  • Total TS/TSX files: $TS_FILES"
    
    # Check if project compiles
    if [ -f "tsconfig.json" ]; then
        echo "  • 🔍 Checking project compilation..."
        if npx tsc --noEmit >/dev/null 2>&1; then
            echo "  • ✅ Project compiles successfully"
        else
            echo "  • ⚠️ Project has compilation errors - run 'npx tsc --noEmit' for details"
        fi
    fi
    
    echo ""
    echo "💡 TypeScript Best Practices:"
    echo "  • Use strict TypeScript configuration"
    echo "  • Avoid 'any' types when possible"
    echo "  • Use union types for multiple possibilities"
    echo "  • Implement proper error handling with typed exceptions"
    echo "  • Use interface segregation principle"
    
    echo ""
    echo "🎯 TypeScript validation complete!"
    
else
    echo "ℹ️ File is not a TypeScript file: $FILE_PATH"
fi

exit 0
Full copyable content
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/typescript-compilation-checker.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}

About this resource

Features

  • Real-time TypeScript compilation checking including compilation checking (automatic TypeScript compilation checking on file changes, type error detection with error identification, compilation validation with validation checking, compilation reporting with compilation status), checking optimization (checking performance with fast checking, checking accuracy with accurate checking, checking efficiency with efficient processing, checking reporting with checking status), checking validation (compilation checking validation with checking verification, type error validation with error verification, compilation accuracy validation with accuracy checking, compilation consistency validation with consistency verification), and checking reporting (compilation checking reporting with checking status, type error reporting with error status, compilation validation reporting with validation status, checking analytics with checking statistics)
  • Type error detection and reporting including error detection (type error detection with error identification, compilation error detection with compilation error identification, type safety error detection with type safety error identification, error reporting with error status), error management (error configuration with error settings, error customization with custom error handling, error filtering with error filtering, error updates with error updates), error optimization (error performance optimization with performance improvement, error accuracy optimization with accuracy improvement, error completeness optimization with completeness improvement, error analytics with error statistics), and error reporting (type error reporting with error status, compilation error reporting with compilation status, type safety error reporting with safety status, error analytics with error statistics)
  • No-emit mode for fast validation including no-emit execution (no-emit TypeScript compilation with fast validation, compilation validation without file emission, validation optimization with performance improvement, validation reporting with validation status), no-emit management (no-emit configuration with no-emit settings, no-emit customization with custom no-emit, no-emit monitoring with no-emit tracking, no-emit updates with no-emit updates), no-emit optimization (no-emit performance optimization with performance improvement, no-emit accuracy optimization with accuracy improvement, no-emit efficiency optimization with efficiency improvement, no-emit analytics with no-emit statistics), and no-emit reporting (no-emit execution reporting with execution status, validation reporting with validation status, no-emit performance reporting with performance status, no-emit analytics with no-emit statistics)
  • TSX and TS file support including file support (TSX and TS file support with file type detection, file extension detection with extension identification, file type validation with type checking, file support reporting with support status), support management (support configuration with support settings, support customization with custom support, support filtering with support filtering, support updates with support updates), support optimization (support performance optimization with performance improvement, support accuracy optimization with accuracy improvement, support completeness optimization with completeness improvement, support analytics with support statistics), and support reporting (file support reporting with support status, file type reporting with type status, file extension reporting with extension status, support analytics with support statistics)
  • Clear error messaging and feedback including messaging (clear error messaging with error communication, error feedback with feedback delivery, error reporting with reporting status, messaging optimization with messaging improvement), messaging management (messaging configuration with messaging settings, messaging customization with custom messaging, messaging filtering with messaging filtering, messaging updates with messaging updates), messaging optimization (messaging performance optimization with performance improvement, messaging accuracy optimization with accuracy improvement, messaging readability optimization with readability improvement, messaging analytics with messaging statistics), and messaging reporting (error messaging reporting with messaging status, error feedback reporting with feedback status, error reporting with reporting status, messaging analytics with messaging statistics)
  • Integration with project tsconfig.json including integration (tsconfig.json integration with configuration support, project configuration detection with config detection, configuration validation with config verification, integration reporting with integration status), integration management (integration configuration with integration settings, integration customization with custom integration, integration monitoring with integration tracking, integration updates with integration updates), integration optimization (integration performance optimization with performance improvement, integration accuracy optimization with accuracy improvement, integration efficiency optimization with efficiency improvement, integration analytics with integration statistics), and integration reporting (tsconfig.json integration reporting with integration status, project configuration reporting with config status, configuration validation reporting with validation status, integration analytics with integration statistics)
  • Strict mode and type safety validation including strict validation (strict mode validation with strict checking, type safety validation with safety checking, strict null checks with null checking, strict validation reporting with validation status), strict management (strict configuration with strict settings, strict customization with custom strict, strict monitoring with strict tracking, strict updates with strict updates), strict optimization (strict performance optimization with performance improvement, strict accuracy optimization with accuracy improvement, strict completeness optimization with completeness improvement, strict analytics with strict statistics), and strict reporting (strict mode reporting with strict status, type safety reporting with safety status, strict null checks reporting with null status, strict analytics with strict statistics)
  • Development workflow integration including continuous type checking (automatic TypeScript compilation checking on file changes, immediate type error detection on file edits, automatic type safety validation on file changes, seamless type checking integration with development workflow), workflow automation (automated type checking without manual intervention, type checking automation with automatic checking, type safety automation with automatic safety checks), and workflow optimization (type checking tracking with checking monitoring, type safety optimization with safety optimization, type quality maintenance with quality checks)

Use Cases

  • Catch TypeScript errors immediately after editing automatically detecting type errors, providing immediate feedback, and enabling rapid error correction
  • Validate type safety before commits automatically checking type safety, validating compilation, and preventing broken TypeScript from being committed
  • Ensure code compiles without errors automatically validating compilation, detecting errors, and ensuring code quality
  • Prevent broken TypeScript from entering codebase automatically detecting type errors, preventing broken code, and maintaining code quality
  • Quick feedback on type-related issues automatically providing type error feedback, enabling rapid iteration, and improving development efficiency
  • Development workflow integration seamlessly integrating TypeScript compilation checking into development workflows without manual type checks or type safety validation

Installation

  1. Create hooks directory: mkdir -p .claude/hooks
  2. Create hook file: touch .claude/hooks/typescript-compilation-checker.sh
  3. Make executable: chmod +x .claude/hooks/typescript-compilation-checker.sh
  4. Add configuration from Hook Configuration section above to .claude/settings.json or ~/.claude/settings.json
  5. Alternative: Use the interactive /hooks command in Claude Code

Config paths

  • Local (not committed): .claude/settings.local.json
  • User settings (global): ~/.claude/settings.json
  • Project-wide (committed): .claude/settings.json

Requirements

  • Claude Code CLI installed
  • Project directory initialized
  • Bash shell available
  • Node.js and npm installed
  • TypeScript installed (npm install -g typescript or npm install --save-dev typescript)
  • jq (optional, for JSON parsing of tool input)

Hook Configuration

{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/typescript-compilation-checker.sh",
      "matchers": ["write", "edit"]
    }
  }
}

Hook Script

#!/bin/bash

# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')

if [ -z "$FILE_PATH" ]; then
  exit 0
fi

# Check if this is a TypeScript file
if [[ "$FILE_PATH" == *.ts ]] || [[ "$FILE_PATH" == *.tsx ]]; then
    echo "🔍 TypeScript Compilation Checker - Validating TypeScript code..."
    echo "📄 File: $FILE_PATH"

    # Check if file exists
    if [ ! -f "$FILE_PATH" ]; then
        echo "⚠️ File not found: $FILE_PATH"
        exit 1
    fi

    # Check if TypeScript is available
    if ! command -v npx >/dev/null 2>&1; then
        echo "⚠️ npx not found - please install Node.js"
        exit 1
    fi

    if ! npx tsc --version >/dev/null 2>&1; then
        echo "⚠️ TypeScript not found - install with: npm install -g typescript"
        exit 1
    fi

    # Get TypeScript version
    TS_VERSION=$(npx tsc --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
    echo "📦 TypeScript version: $TS_VERSION"

    # Check for tsconfig.json
    if [ -f "tsconfig.json" ]; then
        echo "⚙️ Using project tsconfig.json"
        CONFIG_FLAG=""
    else
        echo "⚠️ No tsconfig.json found - using default configuration"
        CONFIG_FLAG="--strict --target es2020 --module esnext --moduleResolution node"
    fi

    echo "🔍 Running TypeScript compilation check..."

    # Run TypeScript compiler in no-emit mode
    if npx tsc --noEmit $CONFIG_FLAG "$FILE_PATH" 2>&1; then
        echo "✅ TypeScript compilation successful - no type errors found"

        # Additional file analysis
        echo ""
        echo "📊 File Analysis:"

        # Count interfaces, types, classes
        INTERFACES=$(grep -c '^interface\\|^export interface' "$FILE_PATH" 2>/dev/null || echo 0)
        TYPES=$(grep -c '^type\\|^export type' "$FILE_PATH" 2>/dev/null || echo 0)
        CLASSES=$(grep -c '^class\\|^export class' "$FILE_PATH" 2>/dev/null || echo 0)
        FUNCTIONS=$(grep -c '^function\\|^export function' "$FILE_PATH" 2>/dev/null || echo 0)

        echo "  • Interfaces: $INTERFACES"
        echo "  • Type aliases: $TYPES"
        echo "  • Classes: $CLASSES"
        echo "  • Functions: $FUNCTIONS"

        # Check for any usage
        if grep -q ': any' "$FILE_PATH" 2>/dev/null; then
            ANY_COUNT=$(grep -c ': any' "$FILE_PATH" 2>/dev/null || echo 0)
            echo "  • ⚠️ 'any' types found: $ANY_COUNT (consider more specific types)"
        fi

        # Check for strict mode compliance
        if grep -q '"use strict"' "$FILE_PATH" 2>/dev/null; then
            echo "  • ✅ Strict mode enabled"
        fi

    else
        echo "❌ TypeScript compilation failed - type errors detected"
        echo ""
        echo "💡 Common fixes:"
        echo "  • Check for missing type annotations"
        echo "  • Verify import statements are correct"
        echo "  • Ensure all variables are properly typed"
        echo "  • Check for undefined/null value handling"
        echo "  • Verify function return types match implementation"
        exit 1
    fi

    # Project-wide TypeScript health check
    echo ""
    echo "🏗️ Project TypeScript Health:"

    # Count total TypeScript files
    TS_FILES=$(find . -name "*.ts" -o -name "*.tsx" | grep -v node_modules | wc -l)
    echo "  • Total TS/TSX files: $TS_FILES"

    # Check if project compiles
    if [ -f "tsconfig.json" ]; then
        echo "  • 🔍 Checking project compilation..."
        if npx tsc --noEmit >/dev/null 2>&1; then
            echo "  • ✅ Project compiles successfully"
        else
            echo "  • ⚠️ Project has compilation errors - run 'npx tsc --noEmit' for details"
        fi
    fi

    echo ""
    echo "💡 TypeScript Best Practices:"
    echo "  • Use strict TypeScript configuration"
    echo "  • Avoid 'any' types when possible"
    echo "  • Use union types for multiple possibilities"
    echo "  • Implement proper error handling with typed exceptions"
    echo "  • Use interface segregation principle"

    echo ""
    echo "🎯 TypeScript validation complete!"

else
    echo "ℹ️ File is not a TypeScript file: $FILE_PATH"
fi

exit 0

Examples

TypeScript Compilation Checker Hook Script

Complete hook script that automatically runs TypeScript compilation checks after editing .ts or .tsx files

#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
  exit 0
fi
if [[ "$FILE_PATH" == *.ts ]] || [[ "$FILE_PATH" == *.tsx ]]; then
    echo "🔍 TypeScript Compilation Checker - Validating TypeScript code..."
    echo "📄 File: $FILE_PATH"
    if [ ! -f "$FILE_PATH" ]; then
        echo "⚠️ File not found: $FILE_PATH"
        exit 1
    fi
    if ! command -v npx >/dev/null 2>&1; then
        echo "⚠️ npx not found - please install Node.js"
        exit 1
    fi
    if ! npx tsc --version >/dev/null 2>&1; then
        echo "⚠️ TypeScript not found - install with: npm install -g typescript"
        exit 1
    fi
    TS_VERSION=$(npx tsc --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
    echo "📦 TypeScript version: $TS_VERSION"
    if [ -f "tsconfig.json" ]; then
        echo "⚙️ Using project tsconfig.json"
        CONFIG_FLAG=""
    else
        echo "⚠️ No tsconfig.json found - using default configuration"
        CONFIG_FLAG="--strict --target es2020 --module esnext --moduleResolution node"
    fi
    echo "🔍 Running TypeScript compilation check..."
    if npx tsc --noEmit $CONFIG_FLAG "$FILE_PATH" 2>&1; then
        echo "✅ TypeScript compilation successful - no type errors found"
    else
        echo "❌ TypeScript compilation failed - type errors detected"
        exit 1
    fi
else
    echo "ℹ️ File is not a TypeScript file: $FILE_PATH"
fi
exit 0

Hook Configuration

Complete hook configuration for .claude/settings.json to enable automatic TypeScript compilation checking

{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/typescript-compilation-checker.sh",
      "matchers": ["write", "edit"]
    }
  }
}

Enhanced TypeScript Compilation Checker with File Analysis

Enhanced hook script with file analysis, type counting, and 'any' type detection

#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
  exit 0
fi
if [[ "$FILE_PATH" == *.ts ]] || [[ "$FILE_PATH" == *.tsx ]]; then
    echo "🔍 TypeScript Compilation Checker - Validating TypeScript code..."
    if [ -f "tsconfig.json" ]; then
        if npx tsc --noEmit --skipLibCheck "$FILE_PATH" 2>&1; then
            echo "✅ TypeScript compilation successful"
            INTERFACES=$(grep -c '^interface\|^export interface' "$FILE_PATH" 2>/dev/null || echo 0)
            TYPES=$(grep -c '^type\|^export type' "$FILE_PATH" 2>/dev/null || echo 0)
            CLASSES=$(grep -c '^class\|^export class' "$FILE_PATH" 2>/dev/null || echo 0)
            FUNCTIONS=$(grep -c '^function\|^export function' "$FILE_PATH" 2>/dev/null || echo 0)
            echo "📊 File Analysis:"
            echo "  • Interfaces: $INTERFACES"
            echo "  • Type aliases: $TYPES"
            echo "  • Classes: $CLASSES"
            echo "  • Functions: $FUNCTIONS"
            if grep -q ': any' "$FILE_PATH" 2>/dev/null; then
                ANY_COUNT=$(grep -c ': any' "$FILE_PATH" 2>/dev/null || echo 0)
                echo "  • ⚠️ 'any' types found: $ANY_COUNT (consider more specific types)"
            fi
        else
            echo "❌ TypeScript compilation failed - type errors detected"
            exit 1
        fi
    fi
fi
exit 0

TypeScript Compilation Checker with Project-Wide Health Check

Enhanced hook script with project-wide TypeScript health check and tsconfig.json integration

#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
  exit 0
fi
if [[ "$FILE_PATH" == *.ts ]] || [[ "$FILE_PATH" == *.tsx ]]; then
    echo "🔍 TypeScript Compilation Checker - Validating TypeScript code..."
    if [ -f "tsconfig.json" ]; then
        echo "⚙️ Using project tsconfig.json"
        if npx tsc --noEmit --skipLibCheck 2>&1; then
            echo "✅ Project compiles successfully"
        else
            echo "⚠️ Project has compilation errors - run 'npx tsc --noEmit' for details"
        fi
    else
        echo "⚠️ No tsconfig.json found - using default configuration"
        if npx tsc --noEmit --strict --target es2020 --module esnext --moduleResolution node "$FILE_PATH" 2>&1; then
            echo "✅ TypeScript compilation successful"
        else
            echo "❌ TypeScript compilation failed - type errors detected"
            exit 1
        fi
    fi
fi
exit 0

TypeScript Compilation Checker Configuration Example

Example TypeScript compilation checker configuration for customizing compilation checking behavior

{
  "typescript_compilation_checker": {
    "enabled": true,
    "no_emit": true,
    "skip_lib_check": true,
    "strict_mode": true,
    "file_extensions": [".ts", ".tsx"],
    "tsconfig_path": "tsconfig.json",
    "default_config": {
      "strict": true,
      "target": "es2020",
      "module": "esnext",
      "moduleResolution": "node"
    },
    "analysis": {
      "count_interfaces": true,
      "count_types": true,
      "count_classes": true,
      "count_functions": true,
      "detect_any_types": true
    },
    "project_health_check": true,
    "exclude_patterns": ["**/node_modules/**", "**/dist/**", "**/build/**"]
  }
}

Troubleshooting

tsc --noEmit checks entire project instead of single file

TypeScript follows imports checking dependencies. Add --skipLibCheck: 'tsc --noEmit --skipLibCheck "$FILE_PATH"' or use --isolatedModules for single-file validation without imports. Verify tsconfig.json includes/excludes. Check TypeScript version.

Compilation fails with module resolution errors for node_modules

Missing @types packages or wrong moduleResolution. Install types: 'npm install --save-dev @types/node @types/react'. Set tsconfig: '"moduleResolution": "node"' or "bundler". Verify node_modules structure. Check TypeScript version compatibility.

Hook shows success but VSCode still displays type errors

Different TS versions between CLI and editor. Check: 'npx tsc --version' vs VSCode version. Sync: install workspace TS: 'npm install --save-dev typescript@latest'. Restart VSCode. Verify tsconfig.json is being used by both.

'any' type detection misses implicit any from missing type annotations

grep pattern only finds explicit ': any'. Enable noImplicitAny in tsconfig.json. Or check tsc output: parse 'implicitly has an any type' from compilation errors for complete detection. Verify strict mode settings.

Project-wide health check freezes on large monorepos

Full tsc scans thousands of files. Skip or timeout: 'timeout 10 npx tsc --noEmit >/dev/null 2>&1' with exit code check. Or remove: comment out project compilation section. Use --skipLibCheck to speed up. Configure tsconfig.json includes/excludes.

TypeScript not found despite npm installation

Verify TypeScript installation: 'npm list typescript' or 'npx tsc --version'. Install globally: 'npm install -g typescript' or locally: 'npm install --save-dev typescript'. Check PATH. Verify Node.js version compatibility.

tsconfig.json not being detected or used

Verify tsconfig.json exists in project root. Check file permissions. Use explicit path: 'npx tsc --project tsconfig.json --noEmit'. Verify tsconfig.json syntax is valid JSON. Check for multiple tsconfig.json files.

Type errors in dependencies not being skipped

Use --skipLibCheck flag: 'npx tsc --noEmit --skipLibCheck'. Configure tsconfig.json: '"skipLibCheck": true'. Verify @types packages are installed. Check TypeScript version supports skipLibCheck.

Source citations

Add this badge to your README

Show that TypeScript Checker is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/hooks/typescript-compilation-checker.svg)](https://heyclau.de/entry/hooks/typescript-compilation-checker)

How it compares

TypeScript Checker side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

Field

Automatically runs TypeScript compiler checks after editing .ts or .tsx files to catch type errors early.

Open dossier

Automatically compiles and validates Svelte components when they are modified.

Open dossier

Automated accessibility testing and compliance checking for web applications following WCAG 2.1 and WCAG 2.2 guidelines. This hook automatically runs accessibility scans on HTML files after they are written or edited, using axe-core for comprehensive WCAG compliance testing.

Open dossier

Validates AWS CloudFormation templates for syntax errors and best practices using cfn-lint v1.40.4+ and AWS CLI v2.27.54+.

Open dossier
Next steps
Trust
Review statusReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewed
Package trustPackage not verifiedPackage not verifiedPackage not verifiedPackage not verified
Source provenanceSource-backedSource-backedSource-backedSource-backed
Submitter
Install riskReview firstReview firstReview firstReview first
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
BrandAWS logoAWS
Categoryhookshookshookshooks
Sourcesource-backedsource-backedsource-backedsource-backed
AuthorJSONboredJSONboredJSONboredJSONbored
Added2025-09-192025-09-192025-09-192025-09-19
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notesRuns automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.Runs automatically after write/edit tool use for .svelte files and may invoke npx svelte-check inside the current project. Uses the local project toolchain and dependencies, so validation can be slow or fail when Svelte dependencies are missing.Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.
Privacy notesReceives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.Reads modified .svelte components, package.json, svelte.config.js, and vite.config.js to infer framework, component, accessibility, and performance signals. Prints component statistics and validation output to the local Claude Code hook output stream.Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.
Prerequisites— none listed— none listed— none listed— none listed
Install
mkdir -p .claude/hooks && touch .claude/hooks/typescript-compilation-checker.sh && chmod +x .claude/hooks/typescript-compilation-checker.sh
mkdir -p .claude/hooks && touch .claude/hooks/svelte-component-compiler.sh && chmod +x .claude/hooks/svelte-component-compiler.sh
mkdir -p .claude/hooks && touch .claude/hooks/accessibility-checker.sh && chmod +x .claude/hooks/accessibility-checker.sh
mkdir -p .claude/hooks && touch .claude/hooks/aws-cloudformation-validator.sh && chmod +x .claude/hooks/aws-cloudformation-validator.sh
Config
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/typescript-compilation-checker.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/svelte-component-compiler.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/accessibility-checker.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/aws-cloudformation-validator.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed
Open 4 picks in the interactive comparison tool

Related guides

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.