UNPKG

mobx-keystone

Version:

A MobX powered state management solution based on data trees with first class support for TypeScript, snapshots, patches and much more

23 lines (22 loc) 1.02 kB
import { AnyStandardType, TypeToData } from '../types/schemas'; /** * Turns an object (array, plain object) into a tree node, * which then can accept calls to `getParent`, `getSnapshot`, etc. * If a tree node is passed it will return the passed argument directly. * Additionally this method will use the type passed to check the value * conforms to the type when model auto type checking is enabled. * * @param type Type checker. * @param value Object to turn into a tree node. * @returns The object as a tree node. */ export declare function toTreeNode<TType extends AnyStandardType, V extends TypeToData<TType>>(type: TType, value: V): V; /** * Turns an object (array, plain object) into a tree node, * which then can accept calls to `getParent`, `getSnapshot`, etc. * If a tree node is passed it will return the passed argument directly. * * @param value Object to turn into a tree node. * @returns The object as a tree node. */ export declare function toTreeNode<T extends object>(value: T): T;