I have a Lerna/Yarn workspaces monorepo with many packages that use TypeScript. Each package.json contains a tsconfig.json and a script “build:compile” that calls tsc to compile the source code.
I have two problems with Visual Code:
There is no way to watch-compile all packages with one command. I can only run tsc watch for each package individually, which is quite cumbersome.
Go to declaration into another package always jumps to the compiled d.ts file, but not to the source code.
For #1, consider using project references to define a master project that references all the packages and then run tsc -b -w
on the master project. (There are also lerna run
and yarn workspaces run
, but perhaps they don't work if you need to watch-compile all packages concurrently?)
For #2, enable the declarationMap
compiler option in tsconfig.json
and rebuild all packages, and then "Go to Definition" should go to the source code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With