Handle circular project references

This commit is contained in:
Sheetal Nandi
2018-09-12 14:58:08 -07:00
parent 5553f36c9d
commit ef2024a487
2 changed files with 99 additions and 64 deletions

View File

@@ -61,6 +61,7 @@ namespace ts {
OutOfDateWithUpstream,
UpstreamOutOfDate,
UpstreamBlocked,
ComputingUpstream,
/**
* Projects with no outputs (i.e. "solution" files)
@@ -76,6 +77,7 @@ namespace ts {
| Status.OutOfDateWithUpstream
| Status.UpstreamOutOfDate
| Status.UpstreamBlocked
| Status.ComputingUpstream
| Status.ContainerOnly;
export namespace Status {
@@ -145,6 +147,13 @@ namespace ts {
upstreamProjectName: string;
}
/**
* Computing status of upstream projects referenced
*/
export interface ComputingUpstream {
type: UpToDateStatusType.ComputingUpstream;
}
/**
* One or more of the project's outputs is older than the newest output of
* an upstream project.
@@ -689,11 +698,17 @@ namespace ts {
let usesPrepend = false;
let upstreamChangedProject: string | undefined;
if (project.projectReferences) {
projectStatus.setValue(project.options.configFilePath as ResolvedConfigFileName, { type: UpToDateStatusType.ComputingUpstream });
for (const ref of project.projectReferences) {
usesPrepend = usesPrepend || !!(ref.prepend);
const resolvedRef = resolveProjectReferencePath(ref);
const refStatus = getUpToDateStatus(parseConfigFile(resolvedRef));
// Its a circular reference ignore the status of this project
if (refStatus.type === UpToDateStatusType.ComputingUpstream) {
continue;
}
// An upstream project is blocked
if (refStatus.type === UpToDateStatusType.Unbuildable) {
return {
@@ -928,9 +943,10 @@ namespace ts {
// Circular
if (temporaryMarks.hasKey(projPath)) {
if (!inCircularContext) {
// TODO:: Do we report this as error?
reportStatus(Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"));
return;
}
return;
}
temporaryMarks.setValue(projPath, true);
@@ -1263,6 +1279,8 @@ namespace ts {
status.reason);
case UpToDateStatusType.ContainerOnly:
// Don't report status on "solution" projects
case UpToDateStatusType.ComputingUpstream:
// Should never leak from getUptoDateStatusWorker
break;
default:
assertType<never>(status);