(ref, types, seen = new Set())
| 223 | // Resolve a union member to its leaf record names, following nested unions and |
| 224 | // single-ref aliases. Every BiDi union bottoms out in records, so this is total. |
| 225 | function unionLeaves(ref, types, seen = new Set()) { |
| 226 | if (seen.has(ref)) return [] |
| 227 | seen.add(ref) |
| 228 | const t = types[ref] |
| 229 | if (!t) return [] |
| 230 | if (t.kind === 'record') return [ref] |
| 231 | if (t.kind === 'union') return t.variants.flatMap((v) => unionLeaves(v, types, seen)) |
| 232 | if (t.kind === 'alias' && t.type?.ref) return unionLeaves(t.type.ref, types, seen) |
| 233 | return [] |
| 234 | } |
| 235 | |
| 236 | // The constant value a record pins on wire key `k`, as `{ value }` (a string or |
| 237 | // `null`), or `{ open: true }` when the field exists but is not constant (a base |
no test coverage detected