Skip to main content

Function: flattenUnion()

function flattenUnion(type): FieldType[];

Defined in: packages/ir/src/helpers.ts:189

Flatten nested unions into a single variant list and drop structurally-identical duplicates, preserving first-seen order. The discriminator of a nested union is not carried up.

Parameters​

ParameterType
type{ discriminator?: { mapping?: Record<string, string>; propertyName: string; }; kind: "union"; variants: FieldType[]; }
type.discriminator?{ mapping?: Record<string, string>; propertyName: string; }
type.discriminator.mapping?Record<string, string>
type.discriminator.propertyNamestring
type.kind"union"
type.variantsFieldType[]

Returns​

FieldType[]