Skip to content

Unexpected error when using config file inheritance with project references #40720

Closed
@OliverJAsh

Description

@OliverJAsh

TypeScript Version: 4.0.2

Search Terms: project references composite configuration file inheritance include files

Code

Reduced test case: https://github.com/OliverJAsh/ts-project-references-config-inheritance-bug. Below I have inlined the code from this repository.

Project structure:

├── shared
│   ├── index.ts
│   ├── tsconfig-base.json
│   ├── tsconfig.json (extends `shared/tsconfig-base.json`)
│   └── typings-base
│       └── globals.d.ts
├── webpack
│   ├── index.ts
│   └── tsconfig.json (extends `shared/tsconfig-base.json`)
└── tsconfig.json (references projects `shared/tsconfig.json` and `webpack/tsconfig.json`)

Contents:

shared/index.ts:

export const a: Unrestricted = 1;

shared/tsconfig-base.json:

{
  "include": ["./typings-base/"]
}

shared/tsconfig.json:

{
  "extends": "./tsconfig-base.json",
  "compilerOptions": {
    "composite": true,
    "outDir": "../target-tsc-build/",
    "rootDir": ".."
  },
  "files": ["./index.ts"]
}

shared/typings-base/globals.d.ts:

type Unrestricted = any;

webpack/index.ts:

export const b: Unrestricted = 1;

webpack/tsconfig.json:

{
  "extends": "../shared/tsconfig-base.json",
  "compilerOptions": {
    "composite": true,
    "outDir": "../target-tsc-build/",
    "rootDir": ".."
  },
  "files": ["./index.ts"],
  "references": [
    {
      "path": "../shared/tsconfig.json"
    }
  ]
}

tsconfig.json:

{
  "references": [
    {
      "path": "./shared/tsconfig.json"
    },
    {
      "path": "./webpack/tsconfig.json"
    }
  ],
  "files": []
}

Expected behavior:

# No errors ✅
tsc --build webpack/tsconfig.json --force --verbose

# No errors ✅
tsc --build tsconfig.json --force --verbose

Actual behavior:

# No errors ✅
tsc --build webpack/tsconfig.json --force --verbose

# Errors ❌
tsc --build tsconfig.json --force --verbose

The unexpected error:

[16:49:43] Projects in this build:
    * shared/tsconfig.json
    * webpack/tsconfig.json
    * tsconfig.json

[16:49:43] Project 'shared/tsconfig.json' is up to date because newest input 'shared/typings-base/globals.d.ts' is older than oldest output 'target-tsc-build/shared/index.js'

[16:49:43] Building project '/Users/oliverash/Development/ts-project-references-config-inheritance-bug/shared/tsconfig.json'...

[16:49:44] Project 'webpack/tsconfig.json' is out of date because oldest output 'target-tsc-build/webpack/index.js' is older than newest input 'shared/tsconfig.json'

[16:49:44] Building project '/Users/oliverash/Development/ts-project-references-config-inheritance-bug/webpack/tsconfig.json'...

webpack/index.ts:1:17 - error TS2304: Cannot find name 'Unrestricted'.

1 export const b: Unrestricted = 1;
                  ~~~~~~~~~~~~


Found 1 error.

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions