{"id":26526,"library":"tsc-hooks","title":"tsc-hooks","description":"tsc-hooks (v1.1.2) is a TypeScript compiler hook system that extends tsc's functionality by allowing custom scripts to run before or after compilation. It integrates via a new 'hooks' array in tsconfig.json, enabling built-in hooks like 'copy-files' (to copy non-TypeScript files) and 'file-permissions' (to set file permissions). The package requires TypeScript ^4.3.2 || ^5.0.2 as a peer dependency. It is actively maintained with a simple configuration approach, differing from alternatives like ts-patch or ttypescript by providing a hook interface rather than patching the compiler API.","status":"active","version":"1.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/swimauger/tsc-hooks","tags":["javascript","TypeScript","Compilation","Hook"],"install":[{"cmd":"npm install tsc-hooks","lang":"bash","label":"npm"},{"cmd":"yarn add tsc-hooks","lang":"bash","label":"yarn"},{"cmd":"pnpm add tsc-hooks","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: requires TypeScript 4.3.2+ or 5.0.2+ for the compiler API and tsc binary.","package":"typescript","optional":false}],"imports":[{"note":"ESM-only package; no CommonJS export. Use import syntax.","wrong":"const tscHooks = require('tsc-hooks')","symbol":"default","correct":"import tscHooks from 'tsc-hooks'"},{"note":"Named export is TSCHooks (capitalized). Not default.","wrong":"import { TscHooks } from 'tsc-hooks'","symbol":"TSCHooks","correct":"import { TSCHooks } from 'tsc-hooks'"},{"note":"HookFunction is a type; use import type for type-only import.","wrong":"import { HookFunction } from 'tsc-hooks'","symbol":"HookFunction","correct":"import type { HookFunction } from 'tsc-hooks'"},{"note":"HookConfig is a type; use import type to avoid runtime errors.","wrong":"import { HookConfig } from 'tsc-hooks'","symbol":"HookConfig","correct":"import type { HookConfig } from 'tsc-hooks'"}],"quickstart":{"code":"// Install: npm install --save-dev tsc-hooks typescript\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"outDir\": \"dist\",\n    \"rootDir\": \"src\"\n  },\n  \"include\": [\"src/**/*\"],\n  \"hooks\": [\"copy-files\"],\n  \"copyFiles\": {\n    \"./src/static/\": \"./dist/static/\"\n  }\n}\n// Then run: npx tsc\n// The copy-files hook will copy static files not handled by tsc.","lang":"typescript","description":"Shows how to configure and use the copy-files hook via tsconfig.json to copy static assets after compilation."},"warnings":[{"fix":"Ensure tsc-hooks is installed and invoked (e.g., via npx tsc) to process hooks; otherwise they are ignored.","message":"Hooks property is a new tsconfig key not supported by tsc directly","severity":"breaking","affected_versions":"all"},{"fix":"Arrange hooks array in desired execution order.","message":"Hook execution order depends on array order in tsconfig.json","severity":"broken","affected_versions":"all"},{"fix":"Use 'exclude' in tsconfig to skip .ts files if they should not be copied.","message":"copy-files hook copies all files matched by 'include' pattern, not just non-TypeScript files; exclude .ts files explicitly if not desired.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade TypeScript to ^5.0.2 or later.","message":"TypeScript 4.x support deprecated; only 5.x recommended.","severity":"deprecated","affected_versions":">=1.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev tsc-hooks`","cause":"Package not installed or not in NODE_PATH.","error":"Cannot find module 'tsc-hooks'"},{"fix":"Use npx tsc instead of plain tsc, or ensure tsc-hooks is required before tsc.","cause":"tsc-hooks not loaded; tsc itself doesn't recognize this option.","error":"Unknown compiler option 'hooks'."},{"fix":"Use ES module import syntax: import tscHooks from 'tsc-hooks'","cause":"Using require('tsc-hooks') instead of import.","error":"TypeError: (0 , tscHooks.default) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}