UNPKG

753 BTypeScriptView Raw
1import { Arbitrary } from '../check/arbitrary/definition/Arbitrary';
2/**
3 * For mutually recursive types
4 *
5 * @example
6 * ```typescript
7 * const { tree } = fc.letrec(tie => ({
8 * tree: fc.oneof({depthFactor: 0.5}, tie('leaf'), tie('node')),
9 * node: fc.tuple(tie('tree'), tie('tree')),
10 * leaf: fc.nat()
11 * }));
12 * // tree is 50% of node, 50% of leaf
13 * // the ratio goes in favor of leaves as we go deeper in the tree (thanks to depthFactor)
14 * ```
15 *
16 * @param builder - Arbitraries builder based on themselves (through `tie`)
17 *
18 * @remarks Since 1.16.0
19 * @public
20 */
21export declare function letrec<T>(builder: (tie: (key: string) => Arbitrary<unknown>) => {
22 [K in keyof T]: Arbitrary<T[K]>;
23}): {
24 [K in keyof T]: Arbitrary<T[K]>;
25};