Skip to content

tsc -b produces different outcomes with same inputs (using project references & typescript@beta) #33770

@kiprasmel

Description

@kiprasmel

TypeScript Version: typescript@beta (3.7.0-beta)

Search Terms:
Project references, compilation fails, tsc -b, yarn tsc -b, yarn workspaces, monorepo

Context:

I've got a similar project set up as https://github.com/RyanCavanaugh/learn-a. Mine also uses yarn-workspaces.

I want to be able to run tsc -b (global typescript installation) and/or tsc -b -w (local typescript installation, defined in package.json). I've tried both.

Expected behavior:
I'm able to consistently get the same output with the same inputs.

Actual behavior:
With the same inputs (source files) the compiler sometimes successfully compiles, and sometimes it fails with errors:

<filename>:69:420 - error TS2307: Cannot find module '@my-project/local-package'.

I've had a higher success rate with the global tsc -b rather than the local yarn run tsc -b by the way. It seems that if one's failing, removing the generated dist files and running the other will work. Strange.

Playground Link:

https://github.com/sarpik/turbo-schedule

git clone https://github.com/sarpik/turbo-schedule.git
# or:  git clone [email protected]:sarpik/turbo-schedule.git
cd turbo-schedule
yarn install

yarn global add [email protected]

tsc -b                  # sometimes works, sometimes doesn't
yarn run purge:build    # clean up
yarn run tsc -b         # sometimes works, sometimes doesn't

Related Issues:
#32028 (comment)
#20148
#26867
#26689

Edit:

I thought this was a problem between tsc -b and yarn run tsc -b, but it isn't - running the compiler either way sometimes fails and sometimes succeeds.

Could this be with my purge:build script? It just removes the ./client/build and ./*/dist, making the project available to be cleanly rebuilt.

Edit v2:

After moving all of my projects' typescript dependency from devDependencies to dependencies, the issue seems to occur a little rarer, but it still happens quite a lot.

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions