Skip to main content

emits_union_alias

Function emits_union_alias 

Source
pub(crate) fn emits_union_alias(schema: &ParsedSchema, sd: &StructDef) -> bool
Expand description

true when the emitted TypeScript for sd must be a discriminated-union alias rather than a named-fields-only interface.

Pure union envelopes are always aliases (existing behavior). A mixed struct (named fields + union) becomes an alias only when it is a referenced data type — service/scoped envelopes keep their legacy interface because their dedicated builder/parse paths never construct or narrow the object type. Without the alias, the generated request serializer switches on variant/data properties the interface does not declare, and the generated payload parser drops the union on the floor (#1616).