TypeScript, Mono-Repositories and Internal Packages / Project References

I am getting quite frustrate with project references / internal projects and the resolving of types for TypeScript. To make it a bit smaller, let's say I have @acme/api-service which exports TRPC types and a Cloudflare Worker, I also have @acme/app which wants to consume this api service's TRPC types. In @acme/api-service I am exporting main / types fields in package.json, I am also using path aliases, and defining global types for it's environment in compilerOptions.types in tsconfig.json. When I don't use project references, and I run tsc --noEmit for type checking in the @acme/app folder I get errors about the missing global types, and the path aliases. When I use project references it seems like that kind of fixes it, but it looks like I need to continuously watch / build the declaration files of @acme/api-service while in development to not get these types out of sync. What is a good solution here, can I make sure that tsc reads the aliases / types from the tsconfig file from @acme/api-service? I am looking for a good setup for this scenario, where I can properly type check the whole mono repo during CI / CD, and making sure that the IDE stays fast since our repository is getting quite big.
N
Nick354d ago
Do you have a hoisted node_modules folder? Using that can make a lot of issues with type dependencies go away There are other ways though like with references