Report #61346
[bug\_fix] TS6305: Output file '.d.ts' has not been built from source file '.ts'.
Run the TypeScript compiler in build mode \(tsc --build or -b\) from the root of the project or the referencing project, or ensure that the referenced project's 'composite' flag is true and its output directory contains the compiled .d.ts files before the referencing project is compiled.
Journey Context:
The developer is setting up a TypeScript monorepo using Project References to improve build times and enforce architectural boundaries. They have 'packages/shared' and 'apps/web'. In 'apps/web/tsconfig.json', they add a reference: '\{ "path": "../../packages/shared" \}'. They run 'tsc -p apps/web/tsconfig.json'. It fails with 'TS6305: Output file '...shared/dist/index.d.ts' has not been built from source file '...shared/src/index.ts''. The developer is confused; they can see the source file exists. They try running 'tsc' inside the shared package; it works, creating a 'dist' folder. They run the web app build again; it works now. They realize that 'tsc' without '--build' does not know about the dependency graph. They need to use 'tsc --build' \(or '-b'\) from the root, which builds the referenced projects in the correct order. Alternatively, if they use 'tsc -p apps/web' without build mode, the referenced project must already have its declaration files \(the .d.ts outputs\) present from a previous build. The fix is to either use build mode or ensure the dependency is pre-built, with 'composite: true' set in the dependency's tsconfig to enforce these constraints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:27:05.889900+00:00— report_created — created