Skip to content
Tutorials Center
My learning

Topics

TypeScript Reference ยท tsconfig: Projects, Files and Watch Options

TypeScript disableSourceOfProjectReferenceRedirect option

Reference for disableSourceOfProjectReferenceRedirect: an editor-only TypeScript option that makes referenced projects load from declaration output.

In an editor, TypeScript normally makes working across project references pleasant: when you import from a referenced project, the language service reads that project's original .ts sources, not its built .d.ts files. Edits in one project show up immediately in the other, and you do not need to rebuild first.

disableSourceOfProjectReferenceRedirect turns that behavior off. The editor then uses the declaration files, exactly as the command-line build does. It is useful in very large setups where loading the sources of every referenced project makes the editor slow.

JSON
{
  "compilerOptions": {
    "composite": true,
    "disableSourceOfProjectReferenceRedirect": true
  }
}

Try it

The option only affects the language service, so these examples model the redirect decision in plain TypeScript.

TypeScript Choosing source or declaration

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

TypeScript Stale output versus live source

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

Syntax

JSON
{ "compilerOptions": { "disableSourceOfProjectReferenceRedirect": true } }
Value Description
false (default) The editor reads source files of referenced projects.
true The editor reads their declaration output; you must rebuild to see changes.

It only has an effect in projects that use composite and references. The command-line compiler already uses declaration files, so tsc output does not depend on this setting.

Usage notes

  • Editor-only. It changes what the language service loads, not what tsc emits or reports.
  • Trade-off. The default gives instant cross-project feedback but loads more source into memory; turning it on is lighter but can show stale types until the next build.
  • Related switches for large repositories are disableSolutionSearching (the editor stops looking for a solution config that owns a file) and disableReferencedProjectLoad (referenced projects are only loaded when needed).
  • Declaration maps make "Go to definition" jump to sources even when declaration files are used.
  • Check first. If the editor feels slow with many references, measure with extendedDiagnostics before you disable anything.