Skip to content

Incorrect tsc --build compilation that is dependent on project references (using NPM workspaces) #50872

Closed
@JSin

Description

@JSin

Bug Report

I am getting results from tsc --build that I don't expect that change depending on the order of the project references order. I have included a repo to best showcase the error.
https://github.com/JSin/ts-bug-project-references

🔎 Search Terms

Compilation differs based on project references order even for projects that do not link.

🕗 Version & Regression Information

  • This is the behavior in every version I tried (4.7.4 and 4.8.3), and I reviewed the FAQ for entries about project references

⏯ Playground Link

Can't be done in Playground, included repo below.
https://github.com/JSin/ts-bug-project-references

💻 Code

Grab repo:

git clone git@github.com:JSin/ts-bug-project-references.git
cd ts-bug-project-references
npm i

To run the issue tsconfig:

npx tsc --build --clean tsconfig.build.issue.json # only needed to run to clean start
npx tsc --build --verbose tsconfig.build.issue.json

To run the working tsconfig but with a different project references order:

npx tsc --build --clean tsconfig.build.working.json # only needed to run to clean start
npx tsc --build --verbose tsconfig.build.working.json

🙁 Actual behavior

Actual behaviour of the tsconfig that causes an error (running npx tsc --build --verbose tsconfig.build.issue.json with a clean repo)

[10:57:52 p.m.] Projects in this build: 
    * packages/b/tsconfig.json
    * packages/a/tsconfig.json
    * tsconfig.build.issue.json

[10:57:52 p.m.] Project 'packages/b/tsconfig.json' is out of date because output file 'packages/b/dist/tsconfig.tsbuildinfo' does not exist

[10:57:52 p.m.] Building project '/development/ts-bug-project-references/packages/b/tsconfig.json'...

[10:57:53 p.m.] Project 'packages/a/tsconfig.json' is out of date because output file 'packages/a/dist/tsconfig.tsbuildinfo' does not exist

[10:57:53 p.m.] Building project '/development/ts-bug-project-references/packages/a/tsconfig.json'...

packages/a/index.ts:1:8 - error TS1192: Module '"/development/ts-bug-project-references/node_modules/@types/pg/index"' has no default export.

1 import pg from "pg";
         ~~


Found 1 error.

🙂 Expected behavior

Can be seen by running npx tsc --build --verbose tsconfig.build.working.json in a clean repo

[11:00:05 p.m.] Projects in this build: 
    * packages/a/tsconfig.json
    * packages/b/tsconfig.json
    * tsconfig.build.working.json

[11:00:05 p.m.] Project 'packages/a/tsconfig.json' is out of date because output file 'packages/a/dist/tsconfig.tsbuildinfo' does not exist

[11:00:05 p.m.] Building project '/development/ts-bug-project-references/packages/a/tsconfig.json'...

[11:00:06 p.m.] Project 'packages/b/tsconfig.json' is out of date because output file 'packages/b/dist/tsconfig.tsbuildinfo' does not exist

[11:00:06 p.m.] Building project '/development/ts-bug-project-references/packages/b/tsconfig.json'...

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