Current Behavior
I wanted to neaten things up a bit in our repo by moving some files and deduplicating tsconfig logic. Unfortunately doing this breaks the TypeScript Project Linking detection. The real problem is that the project linking features don't work unless a number of arbitrary and otherwise unnecessary conditions are met. When these conditions are not met, there is no warning or observable notice (that I have seen, I'm relatively new to nx) other than the fact that the project linking features stop working.
For example, I moved ~/tsconfig.base.json to ~/eng/ts/tsconfig.base.json, which breaks project linking features, even though there's no reason it should break.
The code causing this fragility is in isWorkspaceSetupWithTsSolution(), which is duplicated in 2 different packages in nx:
workspace/utilities/typescript/ts-solution-setup.ts
js/utils/typescript/ts-solution-setup.ts
Any of these changes break project linking without warning:
- Moving the location of the
~/tsconfig.base.json file (there's no other reason it has to be in the repo root)
- Using a different name than
~/tsconfig.base.json
- Omitting empty
files: [] or include: [] arrays from ~/tsconfig.json (this is required even though the empty array could be specified in the base file)
composite: true must be specified in ~/tsconfig.base.json - this one is functionally required, which makes sense, but it should work if provided in a different file
Expected Behavior
Project linking should work as documented long as the functional requirements are in place, eg:
composite: true is set in the ~/tsconfig.json file, after it is combined with any tsconfig files that it extends
- Package manager workspaces is enabled
- Are there any other requirements that are strictly needed to enable it?
Or, if there's a strong backward compatibility concern to preserve unlinked behavior, then add a property to nx.json to enable/disable project linking.
GitHub Repo
https://github.com/johncrim/nx-test-project-linking
Steps to Reproduce
git clone git@github.com:johncrim/nx-test-project-linking.git
nx sync => shows no updates b/c tsconfig.base.json is in ~/eng dir
- Move
~/eng/tsconfig.base.json to ~/tsconfig.base.json and fix the reference in ~/tsconfig.json to point to the new location
nx sync => updates ~/tsconfig.json and ~/lib2/tsconfig.lib.json b/c project linking is detected
Nx Report
Node : 24.10.0
OS : win32-x64
Native Target : x86_64-windows
npm : 11.6.1
daemon : Available
nx (global) : 22.7.1
nx : 22.7.5
@nx/js : 22.7.5
@nx/eslint : 22.7.5
@nx/workspace : 22.7.5
@nx/devkit : 22.7.5
@nx/eslint-plugin : 22.7.5
@nx/vitest : 22.7.5
typescript : 5.9.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/eslint/plugin
@nx/vitest
---------------------------------------
Cache Usage: 0.00 B / 95.10 GB
Failure Logs
Package Manager Version
No response
Operating System
Additional Information
No response
Current Behavior
I wanted to neaten things up a bit in our repo by moving some files and deduplicating tsconfig logic. Unfortunately doing this breaks the TypeScript Project Linking detection. The real problem is that the project linking features don't work unless a number of arbitrary and otherwise unnecessary conditions are met. When these conditions are not met, there is no warning or observable notice (that I have seen, I'm relatively new to nx) other than the fact that the project linking features stop working.
For example, I moved
~/tsconfig.base.jsonto~/eng/ts/tsconfig.base.json, which breaks project linking features, even though there's no reason it should break.The code causing this fragility is in
isWorkspaceSetupWithTsSolution(), which is duplicated in 2 different packages in nx:workspace/utilities/typescript/ts-solution-setup.ts
js/utils/typescript/ts-solution-setup.ts
Any of these changes break project linking without warning:
~/tsconfig.base.jsonfile (there's no other reason it has to be in the repo root)~/tsconfig.base.jsonfiles: []orinclude: []arrays from~/tsconfig.json(this is required even though the empty array could be specified in the base file)composite: truemust be specified in~/tsconfig.base.json- this one is functionally required, which makes sense, but it should work if provided in a different fileExpected Behavior
Project linking should work as documented long as the functional requirements are in place, eg:
composite: trueis set in the~/tsconfig.jsonfile, after it is combined with any tsconfig files that it extendsOr, if there's a strong backward compatibility concern to preserve unlinked behavior, then add a property to nx.json to enable/disable project linking.
GitHub Repo
https://github.com/johncrim/nx-test-project-linking
Steps to Reproduce
git clone git@github.com:johncrim/nx-test-project-linking.gitnx sync=> shows no updates b/c tsconfig.base.json is in~/engdir~/eng/tsconfig.base.jsonto~/tsconfig.base.jsonand fix the reference in~/tsconfig.jsonto point to the new locationnx sync=> updates~/tsconfig.jsonand~/lib2/tsconfig.lib.jsonb/c project linking is detectedNx Report
Failure Logs
Package Manager Version
No response
Operating System
Additional Information
No response