| 568 | document.references.nonRecursives.map((reference) => [reference.$ref, reference.code.Type]), |
| 569 | ) |
| 570 | const expand = (type: string, seen = new Set<string>()): string => { |
| 571 | for (const [reference, value] of references) { |
| 572 | const pattern = `(?<![A-Za-z0-9_$.'"])${reference.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![A-Za-z0-9_$.'"])` |
| 573 | if (!new RegExp(pattern).test(type)) continue |
| 574 | if (seen.has(reference)) { |
| 575 | throw new GenerationError({ reason: `Recursive Promise types are not implemented: ${reference}` }) |
| 576 | } |
| 577 | type = type.replace(new RegExp(pattern, "g"), `(${expand(value, new Set([...seen, reference]))})`) |
| 578 | } |
| 579 | return type |
| 580 | } |
| 581 | return expand(document.codes[0].Type) |
| 582 | .replaceAll(/ & Brand\.Brand<"[^"]+">/g, "") |
| 583 | .replaceAll("Schema.Json", "JsonValue") |