/** * Recursively make all properties optional * From https://stackoverflow.com/questions/45372227/how-to-implement-typescript-deep-partial-mapped-type-not-breaking-array-properti/49936686#49936686 */ export type RecursivePartial = { [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial[] : T[P] extends Readonly[] ? Readonly>[] : RecursivePartial; }; /** Type safe wrapper for Number constructor that takes 'any' */ export function bnToNum(bn: bigint): number { return Number(bn); }