spread-discriminated-model
@azure-tools/typespec-azure-core/spread-discriminated-modelCheck a model with a discriminator has not been used in composition.
A model using @discriminator is meant to be used in a polymorphic context. It should be extended to represent the relation.
Spreading this model is a sign that either the @discriminator decorator is unnecessary or that model extends should have been used instead.
Impact
Section titled “Impact”- Area: SDK
Spreading a discriminated model silently drops the discriminator, which is usually a mistake.
❌ Incorrect
Section titled “❌ Incorrect”@discriminator("kind")model Pet { kind: string;}
model Cat { ...Pet; meow: boolean;}✅ Correct
Section titled “✅ Correct”model Pet { kind: string;}
model Cat { ...Pet; meow: boolean;}@discriminator("kind")model Pet { kind: string;}
model Cat extends Pet { kind: "cat"; meow: boolean;}Suppression
Section titled “Suppression”Suppress only when intended (unlikely); only spread non-discriminated types.