UNPKG

fast-check

Version:

Property based testing framework for JavaScript (like QuickCheck)

21 lines (20 loc) 599 B
import { Arbitrary } from './definition/Arbitrary'; /** * For mutually recursive types * * @example * ```typescript * const { tree } = fc.letrec(tie => ({ * tree: fc.oneof(tie('node'), tie('leaf'), tie('leaf')), * node: fc.tuple(tie('tree'), tie('tree')), * leaf: fc.nat() * })); // tree is 1 / 3 of node, 2 / 3 of leaf * ``` * * @param builder - Arbitraries builder based on themselves (through `tie`) */ export declare function letrec<T>(builder: (tie: (key: string) => Arbitrary<unknown>) => { [K in keyof T]: Arbitrary<T[K]>; }): { [K in keyof T]: Arbitrary<T[K]>; };