install
source · Clone the upstream repo
git clone https://github.com/Intense-Visions/harness-engineering
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/Intense-Visions/harness-engineering "$T" && mkdir -p ~/.claude/skills && cp -r "$T/agents/skills/codex/ts-config-patterns" ~/.claude/skills/intense-visions-harness-engineering-ts-config-patterns-72619d && rm -rf "$T"
manifest:
agents/skills/codex/ts-config-patterns/SKILL.mdsource content
TypeScript Config Patterns
Configure tsconfig with extends, project references, composite builds, and incremental compilation
When to Use
- Setting up tsconfig.json for a new project
- Organizing shared TypeScript configuration across a monorepo
- Enabling project references for faster builds in multi-package repos
- Troubleshooting TypeScript compilation issues
Instructions
- Minimal modern tsconfig for a Node.js/Next.js project:
{ "compilerOptions": { "target": "ES2022", "module": "ESNext", "moduleResolution": "bundler", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", "incremental": true, "paths": { "@/*": ["./src/*"] } }, "include": ["src"], "exclude": ["node_modules", "dist"] }
- Extend a shared base config:
// tsconfig.base.json { "compilerOptions": { "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "isolatedModules": true } } // packages/api/tsconfig.json { "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "./dist", "rootDir": "./src" }, "include": ["src"] }
- Project references for monorepo builds:
// tsconfig.json (root) { "references": [ { "path": "packages/shared" }, { "path": "packages/api" }, { "path": "packages/web" } ], "files": [] } // packages/shared/tsconfig.json { "compilerOptions": { "composite": true, "declaration": true, "outDir": "./dist" }, "include": ["src"] } // packages/api/tsconfig.json { "references": [{ "path": "../shared" }], "compilerOptions": { "composite": true, "outDir": "./dist" } }
Build with:
tsc --build (builds referenced projects in dependency order).
- Incremental compilation — cache type check results:
{ "compilerOptions": { "incremental": true, "tsBuildInfoFile": ".tsbuildinfo" } }
- Separate configs for different concerns:
// tsconfig.json — IDE and type checking (no emit) { "compilerOptions": { "noEmit": true }, "include": ["src", "tests"] } // tsconfig.build.json — production build (emit, no tests) { "extends": "./tsconfig.json", "compilerOptions": { "noEmit": false, "outDir": "dist" }, "include": ["src"], "exclude": ["**/*.test.ts", "**/*.spec.ts"] }
-
Key options explained:
— JavaScript version to emit. Usetarget
for Node 18+,ES2022
for broader compatES2021
— Module system.module
for bundler-based projects,ESNext
for Node.js packagesNodeNext
—moduleResolution
for Vite/webpack/Next.js,bundler
for Node.js librariesNodeNext
— required for esbuild/swc transpilation (one file at a time)isolatedModules
— skip type checkingskipLibCheck
files from dependencies. Almost always enable.d.ts
-
Configure for testing:
// vitest needs jsdom types { "compilerOptions": { "types": ["vitest/globals"] } }
Details
tsconfig.json controls both the TypeScript compiler and the language service (IDE features). Many projects use TypeScript only for type checking (noEmit: true) while a bundler (Vite, esbuild, Next.js) handles actual compilation.
requirements:composite: true
must be setdeclaration: true- All input files must be matched by
or listed inincludefiles
defaults to the directory containingrootDirtsconfig.json- Enables
mode for dependency-aware compilationtsc --build
choices:moduleResolution
— best for projects using Vite, webpack, esbuild, Next.js. Allows extensionless imports,bundler
resolution, andindex.ts
exportspackage.json
/NodeNext
— for pure Node.js packages. RequiresNode16
extensions in imports (even for.js
files). Enforces ESM/CJS boundaries.ts
(legacy) — Node.js CommonJS resolution. Avoid for new projectsnode
vs paths
: baseUrl
paths requires baseUrl in older TypeScript versions but since TypeScript 5.0+, paths can be relative to the tsconfig directory without baseUrl.
Trade-offs:
speeds up compilation significantly — but hides type errors inskipLibCheck: true
files from dependencies.d.ts
speeds up subsequent builds — but creates aincremental: true
file that should be gitignored.tsbuildinfo- Project references enable parallel builds — but add complexity to the monorepo configuration
is required for fast transpilers — but preventsisolatedModules
and namespace merging across filesconst enum
Source
https://typescriptlang.org/tsconfig
Process
- Read the instructions and examples in this document.
- Apply the patterns to your implementation, adapting to your specific context.
- Verify your implementation against the details and edge cases listed above.
Harness Integration
- Type: knowledge — this skill is a reference document, not a procedural workflow.
- No tools or state — consumed as context by other skills and agents.
Success Criteria
- The patterns described in this document are applied correctly in the implementation.
- Edge cases and anti-patterns listed in this document are avoided.