question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`references` are not inherited in `tsconfig.json`

See original GitHub issue

TypeScript Version: 3.1.0-dev.20180914

Search Terms: tsconfig.json extends references inheritance

It seems that the references key is not inherited via the extends mechanism, which surprised me because the handbook doesn’t mention anything special about it.

Demo:

tsconfig.base.json:

{
  "references": [
    { "path": "./some/other/project" }
  ],
  "compilerOptions": {
    "declaration": true,
    "composite": true
  }
}

tsconfig.doesnt-work.json:

{
  "extends": "./tsconfig.base.json"
}

Building tsconfig.doesnt-work.json doesn’t build the reference:

$ tsc -b -f -d tsconfig.doesnt-work.json
[11:12:13] A non-dry build would build project 'C:/demo/tsconfig.doesnt-work.json'

tsconfig.works-but-duplicates-references.json:

{
  "extends": "./tsconfig.base.json",
  "references": [
    { "path": "./some/other/project" }
  ],
}

This is a correct build but I had to duplicate the references key:

$ tsc -b -f -d tsconfig.works-but-duplicates-references.json
[11:12:13] A non-dry build would build project 'C:/demo/tsconfig.works-but-duplicates-references.json'
[11:12:13] A non-dry build would build project 'C:/demo/some/other/project/tsconfig.json'

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:44
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
RyanCavanaughcommented, Oct 1, 2018

This is the intended behavior but we need to document it

7reactions
laszlopandycommented, Apr 17, 2020

In the handbook it says:

files, include and exclude from the inheriting config file overwrite those from the base config file.

Following the principle of lease surprise, references should also inherit and overwrite those from the base config file.

Regarding what Ryan said:

An opaque library that doesn’t intend to expose its reliance on A to its consumer C and leaks no types from A … If references are inherited, then the first scenario is impossible to do.

Is it still impossible if we allow references to override even if it’s empty?

{
    "extends": "./tsconfig-other.json",
    "references": [],
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Reference - Docs on every TSConfig option
The value of extends is a string which contains a path to another configuration file to inherit from. The path may use Node.js...
Read more >
Why is a Typescript project reference using the parent tsconfig ...
Just to put some context to my question: I'd like to move several projects to a single monorepo, but not all the code...
Read more >
tsconfig.json
By invoking tsc with no input files, in which case the compiler searches for the tsconfig.json file starting in the current directory and...
Read more >
TypeScript project references | moon
tsconfig.options.json ​. This file will contain common compiler options that will be inherited by all projects in the monorepo. For project references to ......
Read more >
Angular compiler options
A TypeScript configuration can inherit settings from another file using the extends property. ... When true , does not produce .metadata.json files.
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found