( casesByTag: CasesByTag )
| 6635 | * @since 4.0.0 |
| 6636 | */ |
| 6637 | export function TaggedUnion<const CasesByTag extends Record<string, Struct.Fields>>( |
| 6638 | casesByTag: CasesByTag |
| 6639 | ): TaggedUnion<{ readonly [K in keyof CasesByTag & string]: TaggedStruct<K, CasesByTag[K]> }> { |
| 6640 | const cases: any = {} |
| 6641 | const members: any = [] |
| 6642 | for (const key of Object.keys(casesByTag)) { |
| 6643 | const member = TaggedStruct(key, casesByTag[key]) |
| 6644 | InternalRecord.assignProperty(cases, key, member) |
| 6645 | members.push(member) |
| 6646 | } |
| 6647 | const union = Union(members) |
| 6648 | const { tag, guards, isAnyOf, match, matchOrElse } = toTaggedUnion("_tag")(union) |
| 6649 | return make(union.ast, { tag, cases, isAnyOf, guards, match, matchOrElse }) |
| 6650 | } |
| 6651 | /** |
| 6652 | * Type-level representation returned by {@link Opaque}. |
| 6653 | * |
nothing calls this directly
no test coverage detected