UNPKG

mobx-state-tree

Version:

Opinionated, transactional, MobX powered state container

19 lines (18 loc) 1.39 kB
import { IType, Type } from "../type"; import { Node } from "../../core"; import { IContext, IValidationResult } from "../type-checker"; export declare class Refinement<S, T> extends Type<S, T> { readonly type: IType<any, any>; readonly predicate: (v: any) => boolean; readonly message: (v: any) => string; readonly flags: number; constructor(name: string, type: IType<any, any>, predicate: (v: any) => boolean, message: (v: any) => string); describe(): string; instantiate(parent: Node, subpath: string, environment: any, value: any): Node; isAssignableFrom(type: IType<any, any>): boolean; isValidSnapshot(value: any, context: IContext): IValidationResult; } export declare function refinement<T>(name: string, type: IType<T, T>, predicate: (snapshot: T) => boolean, message?: string | ((v: any) => string)): IType<T, T>; export declare function refinement<S, T extends S, U extends S>(name: string, type: IType<S, T>, predicate: (snapshot: S) => snapshot is U, message?: string | ((v: any) => string)): IType<S, U>; export declare function refinement<S, T extends S, U extends S>(type: IType<S, T>, predicate: (snapshot: S) => snapshot is U, message?: string | ((v: any) => string)): IType<S, U>; export declare function refinement<T>(type: IType<T, T>, predicate: (snapshot: T) => boolean, message?: string | ((v: any) => string)): IType<T, T>;