Jakub notes • engineering

TypeScript: Project References

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

Project references allow to structure codebase into smaller pieces and improves build time. Build mode --build for tsc together with Project references makes builds faster.

{
    "references": [
        { "path": "../src" }
    ]
}

Referenced projects must have the new composite setting enabled.

declarationMap allows IDEs to "Go to Definition".

Composite

composite: true

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

Build tools determine if projects are up-to-date.

It is used for Project References. rootDir, include or files, and declaration is used with this option.

Build mode

Runningtsc --build is necessary to build dependencies.

Configs structure

Centralize common options in root tsconfig.

Use src/tsconfig.json with all references https://github.com/microsoft/TypeScript/blob/main/src/tsconfig.json.