Skip to content

TypeScript 3.7+ regression issue in Lerna monorepo w/ Yarn Workspaces and composite projects #35768

@amirburbea

Description

@amirburbea

TypeScript Version: 3.7.3

Node Version: 12.13.1

Search Terms: lerna, monorepo, yarn, workspaces

Problem Description:
TypeScript 3.7+ seems to have issues in a Lerna monorepo using yarn workspaces. TypeScript 3.6.4 does not exhibit the same problem. In the example repo (https://github.com/amirburbea/ts-37-issue), there are two projects @issue/utilities and @issues/server.

@issue/utilities is a typescript composite library. For the purpose of keeping it simple, this project exports a single default function - but I experienced this issue in a signficantly larger project with named exports.

@issue/server is a node application that invokes the function exported in @issue/utilities.

There are several scripts you can run at the root when testing which will save a great deal of time

  • yarn build: Instructs typescript to build the projects.
  • yarn clean: Instructs every project to delete their build outputs and tsconfig.tsbuildinfo
  • yarn rebuild: Runs clean and then build
  • yarn start: Runs build and then starts the output of @issue/server

In general, both in TypeScript 3.6.4 and TypeScript 3.7.3, the code will transpile and afterwards, run identically.

The issue is in the editing experience. If you build and then open the file packages/server/src/index.ts in VS Code, typescript initializes, and when that process is complete hovering over line 4 run(); will show that intellisense has an understanding of the exported function from @issue/utilities.

image

Now simply add a blank line at the end of the file - TypeScript will suddenly not understand the import of @issue/utilities (the import will have squiggly red lines under it and the type will be unknown) until I again reload the window making editing a painful experience. I experienced this in both Visual Studio Code 1.4.1.0 and Visual Studio 2019 16.4.2 almost identically.

image

I upgraded the two package.json to use typescript 3.8 daily build and got the same error. I downgrade them to use typescript 3.6.4 and the issue goes away.

As an FYI, my own project structure (which this example repo mirrors) is based on a sample posted by @DanielRosenwasser when composite was first introduced, but I'm happy to make changes to my tsconfig files if someone can suggest a workaround.

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