Skip to content

legacy-hierarchy-building-circular-reference

Id
@azure-tools/typespec-client-generator-core/legacy-hierarchy-building-circular-reference

Severity: error

This diagnostic is issued when @hierarchyBuilding creates a recursive base-type chain.

  • Area: Legacy SDK inheritance rebasing. Blocks hierarchy rebasing because it would create a circular generated base-model chain.
  • Not affected: The original TypeSpec inheritance declarations are unchanged.
@usage(Usage.input)
namespace TestService;
model A extends B {
propA: string;
}
@hierarchyBuilding(A) // rebasing `B` onto `A` creates a circular base chain
model B extends C {
propB: string;
}
model C {
propC: string;
}

TCGC reports:

@hierarchyBuilding decorator causes recursive base type reference.

Remove or change the @hierarchyBuilding decorator so the rebased hierarchy is acyclic.

@usage(Usage.input)
namespace TestService;
model A extends B {
propA: string;
}
model B extends C {
propB: string;
}
model C {
propC: string;
}