typescript build_error ai_generated true

TS6305: Output file has not been built from source file. Referenced project may need to be built.

ID: typescript/ts-project-reference-error

Also available as: JSON · Markdown
86%Fix Rate
88%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
5 active

Root Cause

Referenced project has not been built or is stale. Run tsc --build to compile project references in correct order.

generic

Workarounds

  1. 92% success Build all project references with tsc --build
    # Build all referenced projects:
    tsc --build
    # Or force rebuild:
    tsc --build --force
    # Clean and rebuild:
    tsc --build --clean && tsc --build

    Sources: https://www.typescriptlang.org/docs/handbook/project-references.html

  2. 87% success Ensure composite and declaration are enabled in referenced projects
    // Referenced project's tsconfig.json:
    {
      "compilerOptions": {
        "composite": true,
        "declaration": true,
        "declarationMap": true
      }
    }

    Sources: https://www.typescriptlang.org/tsconfig#composite

Dead Ends

Common approaches that don't work:

  1. Remove project references and use regular imports 60% fail

    Loses incremental build benefits and may create circular dependency issues in monorepos

Error Chain

Leads to:
Preceded by:
Frequently confused with: