Skip to content

[I] Union

Alternatives described by ordered variants, from either a union declaration or an expression.

PropertyModifierTypeDescriptionOverridesInherited from
baseType?publicEnum | Model | Scalar | UnionExperimental Type declared with the extends clause of a union statement. Union variants are constrained to be assignable to this model, scalar, enum, or union; violations are reported as diagnostics. Validation is deferred for uninstantiated template declarations because their variants can contain unresolved template parameters. Each template instance is validated instead. This is only set for named unions declared with an extends clause. It documents a constraint: it does not imply a subclassing relationship, it does not mean the union is extensible, and it has no interaction with @discriminator. Emitters should not require this to be present: a union with the same variants and no extends clause should ideally be handled the same way.--
creating?publictrueIf the type is currently being created.-BaseType.creating
decoratorspublicDecoratorApplication[]Applications used when finishing this type, including copied or synthesized applications.-DecoratedType.decorators
entityKindreadonly"Type"Distinguishes semantic types from values and parameter constraints.-BaseType.entityKind
expressionpublicbooleanWhether the union is used in expression position, including both `ABandunion { … }`.-
instantiationParameters?publicType[]Legacy instantiation metadata. The compiler’s type checker does not populate this field, so its absence does not indicate whether this type is a template instance.-BaseType.instantiationParameters
isFinishedpublicbooleanReflect if a type has been finished(Decorators have been called). There is multiple reasons a type might not be finished: - a template declaration will not - a template instance that argument that are still template parameters - a template instance that is only partially instantiated(like a templated operation inside a templated interface)-BaseType.isFinished
kindpublic"Union"Discriminant for a union of types rather than a single variant.BaseType.kind-
name?publicstringDeclared name, when present; expression unions can also retain a declaration-expression name.--
namespace?publicNamespaceContaining namespace, when associated with a namespace.--
node?public| UnionStatementNode | UnionDeclarationExpressionNode | UnionExpressionNodeNode used to construct this type. If the node is undefined it means the type was dynamically built. With typekit for example.BaseType.node-
templateMapper?publicTypeMapperArgument substitutions for an instantiation; absent on an uninstantiated declaration.-TemplatedTypeBase.templateMapper
templateNode?publicNodeOriginating template node, when retained separately from the type’s source node.-TemplatedTypeBase.templateNode
variantspublicRekeyableMap<string | symbol, UnionVariant>The variants of the union. Variants are ordered in order that they appear in source.--