UNPKG

mobx-bonsai

Version:

A fast lightweight alternative to MobX-State-Tree + Y.js two-way binding

16 lines (15 loc) 718 B
type ExtractArrayValue<T> = T extends Array<infer V> ? V : never; /** * Transforms an array (with values of type V) into a Set<V> (getter). * * @template T - Type of the containing object * @template K - Type of the property key in T that will be transformed * * @param this - The object containing the property to transform * @param propName - The name of the property to transform into a Set * @returns A function that returns a Set backed by the values from the array property */ export declare function arrayToSetTransform<T extends { [k in K]?: Array<any> | null | undefined; }, K extends keyof T>(propName: K): (this: T) => Set<ExtractArrayValue<T[K]>> | Extract<T[K], undefined | null>; export {};