After extensive testing, I've come to realize that when executing tsc in a project with a specific dependency, the compilation process succeeds as long as any version of that dependency exists somewhere along Node's module resolution path on my system.
For example:
- Consider a monorepo managed through yarn workspaces which includes two packages (project_1 and project_2)
- If project_1 lists a dependency dep_1 in its package.json file
- Upon running yarn install and adding dep_1 to the root node_modules directory
I have found that I can now utilize import statements for dep_1 within project_2 without explicitly including dep_1 in the package.json of project_2. Strangely enough, tsc does not raise any complaints during compilation.
This has sparked my curiosity - is there a way to adjust this behavior so that Typescript recognizes the dependencies specified in each project's package.json file?