no-override-props
@azure-tools/typespec-azure-resource-manager/no-override-propsWarns when a model redefines a property that is already defined in one of its base models. Repeating inherited properties in a child model is an anti-pattern for Azure APIs and can cause problems with OpenAPI tooling and some language representations of the models.
Overriding an inherited property is allowed when:
- The overriding property has the same type as the inherited one (by identity). Type aliases resolve to the same underlying type, and template instantiations are cached, so this naturally covers cases such as redefining
systemData: SystemData(alias) where the parent usessystemData: Foundations.SystemData, or the implicittags: Record<string>cloned into a model that usesis TrackedResource<...>. - Both the inherited property and the overriding property are compatible scalars — that is, both reduce to the same scalar family (
string,numeric, orboolean). For example, an inherited property of typestringmay be overridden by astring, by a scalar that extendsstring, by a string literal, by a string-valued enum, or by an open or closed string union.
❌ Incorrect
Section titled “❌ Incorrect”@armProviderNamespacenamespace MyService;
model InnerBase { a: string;}
model InnerDerived extends InnerBase { b: string;}
model Base { nested: InnerBase;}
model Child extends Base { nested: InnerDerived; // narrows the inherited "nested" to a derived model}✅ Correct
Section titled “✅ Correct”@armProviderNamespacenamespace MyService;
model Base { id: string; commonProp: string;}
model Child extends Base { otherProp: string;}✅ Correct (compatible scalar override)
Section titled “✅ Correct (compatible scalar override)”@armProviderNamespacenamespace MyService;
@discriminator("kind")model Pet { kind: string; weight: int32;}
model Cat extends Pet { kind: "cat"; // allowed: string and string literal are compatible scalars meow: boolean;}Reviewer advice
Section titled “Reviewer advice”Impacts generated SDKs and Tooling: overridden inherited properties can make the breaking-change tool crash and are not supported by most languages. Ask the author to remove overridden properties from the base type so they are represented only in leaf types. Accept a suppression only with SDK signoff.