You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Referenced projects must have the new composite setting enabled" does not hold true #60465
The above link is a project created from the vite react-ts template (https://vite.new/react-ts).
It uses project references in tsconfig.json, but no composite: true specified in both tsconfig.app.json and tsconfig.node.json.
Referenced projects must have the new composite setting enabled.
🙁 Actual behavior
The project builds (npm run build) successfully without composite: true.
🙂 Expected behavior
If I understand correctly, the documentation means I have to specify composite: true when using references. I'd expect an error or warning if I didn't follow the guide.
Additional information about the issue
I'm curious whether it's a bug or a feature.
If it's a bug, what's the expected behavior?
If it's a feature, I'd like to see the documentation updated accordingly.
Reacted by Kirk Waiblinger, Vahid Mohammadi, Eli and Aleksey Shestakov
changed the title [-]"Referenced projects must have the new composite setting enabled" does not holds true[/-][+]"Referenced projects must have the new composite setting enabled" does not hold true[/+]on Nov 10, 2024
Referenced projects must have the new composite setting enabled.
what they mean is that if project A references project B, the latter must have composite: true. In your example, however, your two projects (tsconfig.app.json and tsconfig.node.json) don't reference each other.¹ They are merely referenced by the main ("solution-style") tsconfig.json, in which case you don't need the composite: true. I agree that the docs could be a bit more explicit about this.
¹) In your case (tsconfig.app.json and tsconfig.node.json) this is likely not needed since Node/config code will likely never import application code or vice versa. However, references will be needed as soon as one project needs to import code from another project (that is type-checked with a different tsconfig). For an example please see the tsconfigs in https://github.com/microsoft/TypeScript/tree/main/src and its subfolders.
This really needs to be clarified in the docs. The fact that you can use project references without composite, and without requiring composite and "noEmit": false to reference multiple tsconfig files that don't reference each other is quite useful for many cases, such as specifying project config files in their own separate tsconfig for ESLint type checking rules.
Activity
[-]"Referenced projects must have the new composite setting enabled" does not holds true[/-][+]"Referenced projects must have the new composite setting enabled" does not hold true[/+]codethief commentedon Nov 11, 2024
When the docs say
what they mean is that if project A references project B, the latter must have
composite: true. In your example, however, your two projects (tsconfig.app.jsonandtsconfig.node.json) don't reference each other.¹ They are merely referenced by the main ("solution-style")tsconfig.json, in which case you don't need thecomposite: true. I agree that the docs could be a bit more explicit about this.¹) In your case (
tsconfig.app.jsonandtsconfig.node.json) this is likely not needed since Node/config code will likely never import application code or vice versa. However,referenceswill be needed as soon as one project needs to import code from another project (that is type-checked with a different tsconfig). For an example please see the tsconfigs in https://github.com/microsoft/TypeScript/tree/main/src and its subfolders.haoqunjiang commentedon Nov 11, 2024
I see. So solution-style references don't require
composite; only cross-references needcomposite?codethief commentedon Nov 11, 2024
Yes, at least that's been my understanding.
haoqunjiang commentedon Nov 13, 2024
I found that the TypeScript 5.7 RC release blog has confirmed this behavior:
https://devblogs.microsoft.com/typescript/announcing-typescript-5-7-rc/#faster-project-ownership-checks-in-editors-for-composite-projects:~:text=every%20project%20that%20can%20be%20referenced%20by%20another%20(non%2Dworkspace)%20project%20must%20enable%20a%20flag%20called%20composite%2C
fix: remove `composite: true` from tsconfigs
fix: remove `composite: true` from tsconfigs
segevfiner commentedon Mar 11, 2025
This really needs to be clarified in the docs. The fact that you can use project references without composite, and without requiring
compositeand"noEmit": falseto reference multiple tsconfig files that don't reference each other is quite useful for many cases, such as specifying project config files in their own separate tsconfig for ESLint type checking rules.create-vue already creates projects using this.
fix(@schematics/angular): drop composite in tsconfig
fix(@schematics/angular): drop composite in tsconfig
chore: remove `composite` from frontend and backend packages
fix: composite option is not needed