You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeScript 3.7+ regression issue in Lerna monorepo w/ Yarn Workspaces and composite projects #35768
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.
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.
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 Daniel Rosenwasser (@DanielRosenwasser) when composite was first introduced, but I'm happy to make changes to my tsconfig files if someone can suggest a workaround.
Not only does lerna connect the references by a simlink, but the node_modules folder is at the repository root (and not at each project level) - I wonder if somehow that's what's breaking typescript.
changed the title [-]TypeScript 3.7+ issue with Lerna monorepo utilizing Yarn Workspaces and composite projects[/-][+]TypeScript 3.7+ regression issue with Lerna monorepo utilizing Yarn Workspaces and composite projects[/+]on Dec 19, 2019
changed the title [-]TypeScript 3.7+ regression issue with Lerna monorepo utilizing Yarn Workspaces and composite projects[/-][+]TypeScript 3.7+ regression issue with Lerna monorepo w/ Yarn Workspaces and composite projects[/+]on Dec 19, 2019
changed the title [-]TypeScript 3.7+ regression issue with Lerna monorepo w/ Yarn Workspaces and composite projects[/-][+]TypeScript 3.7+ regression issue in Lerna monorepo w/ Yarn Workspaces and composite projects[/+]on Dec 19, 2019
Actually I'm able to get this to stop breaking with a workaround that says I should add a baseUrl and paths to the @issues/server tsconfig. I guess I'm willing to do that, but it seems unnecessarily verbose and was not required in typescript 3.6.4
Activity
amirburbea commentedon Dec 19, 2019
Not only does
lernaconnect the references by a simlink, but thenode_modulesfolder is at the repository root (and not at each project level) - I wonder if somehow that's what's breaking typescript.[-]TypeScript 3.7+ issue with Lerna monorepo utilizing Yarn Workspaces and composite projects[/-][+]TypeScript 3.7+ regression issue with Lerna monorepo utilizing Yarn Workspaces and composite projects[/+][-]TypeScript 3.7+ regression issue with Lerna monorepo utilizing Yarn Workspaces and composite projects[/-][+]TypeScript 3.7+ regression issue with Lerna monorepo w/ Yarn Workspaces and composite projects[/+][-]TypeScript 3.7+ regression issue with Lerna monorepo w/ Yarn Workspaces and composite projects[/-][+]TypeScript 3.7+ regression issue in Lerna monorepo w/ Yarn Workspaces and composite projects[/+]amirburbea commentedon Dec 19, 2019
Actually I'm able to get this to stop breaking with a workaround that says I should add a
baseUrlandpathsto the@issues/servertsconfig. I guess I'm willing to do that, but it seems unnecessarily verbose and was not required in typescript 3.6.4{ "compilerOptions": { "outDir": "lib", "rootDir": "src", "baseUrl": "../../", "paths": { "@issue/utilities": ["packages/utilities"] } }, "exclude": ["./lib/", "./node_modules/"], "extends": "../tsconfig.base.json", "references": [{ "path": "../utilities" }] }sheetalkamat commentedon Dec 19, 2019
Note that this issue repros only when
preserveSymlinksis set totrueamirburbea commentedon Dec 20, 2019
Does this mean that in TS3.8 this will work without me specifically putting in the baseUrl/paths?