-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect order with project references, extends tsconfig.json and yarn workspaces #29643
Comments
I think this is working as intended. The references section is suppose to be used to get the dependency list and determine the order of the build. |
Does Typescript not do a topological sorting of the project references? |
Its kind of depth first So even though the out config references Project1 and Project2 in that order if Project1 references Project2 then Project2 comes before Project1. |
I'm a bit confused now. You say the references section should "determine the order of the build". My understanding of project references is based on this document: https://www.typescriptlang.org/docs/handbook/project-references.html which states that the Also you said:
Which to me sounds like you are agreeing with my assessment that TS should be able to figure out the order automatically. The Project References page also contains this:
I interpreted this as ts being able to figure out the order of projects thanks to their project reference links? Is this a misunderstanding? |
@sgronblo to have tsc do a correct topological sort, you need to also maintain a tsc computes the overall dependency graph by combining all these It has been pointed out that this is a duplication of effort and tsc could just use |
@yortus Yes, and that is exactly what my sample project is trying to demonstrate. There is a top level "solution" tsconfig.json for convenience, but if you look at the tsconfig.json of the "client" project you would see that it references the "core" project but still tsc ignores that relationship for this specific case. |
@sgronblo yes I see now. I suspect the problem is with |
@yortus Yes. I guess I should have made it clearer that defining the references directly in /client/src/tsconfig.json seems to solve the problem. At least I think it did, when trying the other day. |
@sgronblo yes it's in your OP, sorry I skimmed it too fast. I took a look at the tsc source, in particular the Not sure it this is by design, or has just been overlooked, since the If this is working as intended, I think the documentation should clearly state that references are not inherited by |
@yortus Thanks for checking. I think probably some more detailed confirmation by someone on the TS team is required to tell whether this is actually "working as intended". |
#27098 tracks the inheritance. |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
TypeScript Version: 3.4.0-dev.20190129
Search Terms:
project references order
Code
I made a small PoC here: https://github.com/sgronblo/tsc-build-order-failure
Run
yarn install
and thenyarn build
to see the build failure.Expected behavior:
tsc --build figures out that the client project depends on the core project and builds core before client/src. Even though the project "references" section of the top level "meta" tsconfig.json file happens to list client/src before core. There should be a dependency relationship between client and core because client/src/tsconfig.json extends ../tsconfig.json which defines the reference.
Actual behavior:
tsc just tries to build the projects in the order they are listed in the top level "references" section. When it tries to build client, core has not yet been built, which results in a build error.
The text was updated successfully, but these errors were encountered: