-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript 3.7+ regression issue in Lerna monorepo w/ Yarn Workspaces and composite projects #35768
Comments
Not only does |
Actually I'm able to get this to stop breaking with a workaround that says I should add a {
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"baseUrl": "../../",
"paths": { "@issue/utilities": ["packages/utilities"] }
},
"exclude": ["./lib/", "./node_modules/"],
"extends": "../tsconfig.base.json",
"references": [{ "path": "../utilities" }]
} |
Note that this issue repros only when |
Does this mean that in TS3.8 this will work without me specifically putting in the baseUrl/paths? |
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 andtsconfig.tsbuildinfo
yarn rebuild
: Runsclean
and thenbuild
yarn start
: Runsbuild
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 4run();
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 @DanielRosenwasser when
composite
was first introduced, but I'm happy to make changes to my tsconfig files if someone can suggest a workaround.The text was updated successfully, but these errors were encountered: