(ref, types, seen = new Set())
| 321 | // Resolve a union member to its leaf record names, following nested unions and |
| 322 | // single-ref aliases. Every BiDi union bottoms out in records, so this is total. |
| 323 | function unionLeaves(ref, types, seen = new Set()) { |
| 324 | if (seen.has(ref)) return [] |
| 325 | seen.add(ref) |
| 326 | const t = types[ref] |
| 327 | if (!t) return [] |
| 328 | if (t.kind === 'record') return [ref] |
| 329 | if (t.kind === 'union') return t.variants.flatMap((v) => unionLeaves(v, types, seen)) |
| 330 | if (t.kind === 'alias' && t.type?.ref) return unionLeaves(t.type.ref, types, seen) |
| 331 | return [] |
| 332 | } |
| 333 | |
| 334 | // Whether a union variant is an object (record) type — following aliases and nested |
| 335 | // unions to their leaves. An enum, or an alias to a primitive/list/map (or an inline |
no test coverage detected