Report #9753
[bug\_fix] Project references may not form a circular dependency
Refactor the code to eliminate the circular dependency between projects, typically by extracting the shared code into a separate package that both projects can depend on, or by using dynamic imports \(\`import\(\)\`\) to break the static import cycle. Root cause: TypeScript's project references \(composite projects\) require a strict Directed Acyclic Graph \(DAG\) structure. Circular references prevent the compiler from determining a valid build order.
Journey Context:
The developer is architecting a TypeScript monorepo using project references for incremental builds. They have three packages: \`core\`, \`utils\`, and \`app\`. \`app\` references both \`core\` and \`utils\`. \`core\` references \`utils\`. While refactoring, they move a helper function from \`core\` that depends on a type defined in \`utils\`, but accidentally create an import in \`utils\` that imports a constant from \`core\` \(perhaps for a default configuration value\). When they run \`tsc --build\`, TypeScript reports: "Project 'packages/utils/tsconfig.json' may not disable 'composite' because it is referenced by project 'packages/core/tsconfig.json'." followed by or instead "Project references may not form a circular dependency." The developer examines the \`references\` arrays in the tsconfig files and sees no obvious cycle there—\`utils\` doesn't reference \`core\` in its config. However, they check the actual source code imports and discover that \`utils/index.ts\` imports \`\{ DEFAULT\_CONFIG \} from '../core'\`, while \`core/index.ts\` imports \`type \{ Helper \} from '../utils'\`. This creates a runtime dependency cycle that mirrors in the project graph. To resolve this, the developer extracts \`DEFAULT\_CONFIG\` and the type \`Helper\` into a new package called \`shared\`, which has no dependencies on \`core\` or \`utils\`. Both \`core\` and \`utils\` then reference \`shared\`, breaking the cycle and restoring the DAG structure required by TypeScript's project reference system.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:54:23.005114+00:00— report_created — created