ARTICLE AD BOX
I'm facing the following problem within a project that includes Nx:
error TS6059: File '/libs/lib1/lib1.ts' is not under 'rootDir' '/libs/lib2'. 'rootDir' is expected to contain all source files. 1 export * from './lib/lib2';The above error appears every time I try to import an exported function from one library into another. I asked different LLMs, and all of them suggested modifying the tsconfig.json of each library to include this line:
"rootDir": "../../libs"The problem is that this feels wrong. By doing this, we are telling TypeScript that the root of every library isn't the library itself, but the parent directory containing all of them. Thus, from TypeScript's point of view, the whole libs folder becomes a single big project.
Furthermore, checking some public Nx projects online (like this one), I noticed that this approach is never used.
I assume Nx natively supports importing one library from another, and if such a workaround were required, it would have already been included in the default generators.
Before applying this fix across my workspace, I wanted to ask: is changing the rootDir actually a best practice in this scenario, or is there a proper, Nx-native way to resolve this TS6059 error?
Thank you!
