Skip to content

TypeScript

Configuration hierarchy, project references, and per-package tsconfig conventions.

Every package in the repository shares one compiler baseline and participates in a project-reference graph managed by Nx.

tsconfig.base.json at the repository root defines every compiler option that applies across the entire codebase — strict flags, module resolution, and path aliases used for local project linking.

tsconfig.base.json
{
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"paths": {
"@applications/frontend/*": ["./applications/frontend/*"]
}
}
}

composite: true and declaration: true are required for TypeScript project references. They allow the compiler to check each package individually and cache the result in a .tsbuildinfo file, so subsequent type-checks only process what has changed rather than reloading the whole codebase.

tsconfig.json at the root extends that base and registers every package as a reference. Its files array is intentionally empty — this file is not a compilation entry point; it is a registry. TypeScript uses it to resolve cross-package types in editors and during a repository-wide tsc --build, delegating all actual compilation to each package’s own configuration.

tsconfig.json
{
"extends": "./tsconfig.base.json",
"files": [],
"references": [{ "path": "./applications/frontend" }, { "path": "./applications/mcp-server" }]
}

Each package has a tsconfig.json that extends the root base and serves the same coordinator role as the root — files is empty and compilation is delegated to the package-specific configuration file referenced below it.

<package>/tsconfig.json
{
"extends": "../../tsconfig.base.json",
"files": [],
"references": [{ "path": "./tsconfig.app.json" }]
}

Applications, orchestrators, and services use tsconfig.app.json. It extends the root base, declares which source files to compile, and applies any package-specific compilerOptions overrides.

<package>/tsconfig.app.json
{
"extends": "../../tsconfig.base.json",
"include": ["src/**/*.ts"],
"references": [],
"compilerOptions": {
"outDir": "./tsbuild",
"types": ["bun"]
}
}

Libraries use tsconfig.lib.json in place of tsconfig.app.json, following the same shape but typically excluding source that applies only to the consuming runtime.

<package>/tsconfig.json (library)
{ "path": "./tsconfig.lib.json" }
{ "path": "./tsconfig.app.json" }