import { TypeFlags } from '../type-flags'; import { IType, Type } from '../Type'; import { IContext, IValidationResult } from '../type-checker'; import { IStateTreeNode } from '../../core/NodeUtils'; import { ObjectNode } from '../../core/ObjectNode'; import { INode } from '../../core/interface'; export declare class StoredReference { readonly mode: 'identifier' | 'object'; readonly value: any; constructor(mode: 'identifier' | 'object', value: any); } export declare abstract class BaseReferenceType extends Type { protected readonly targetType: IType; readonly flags: TypeFlags; constructor(targetType: IType); readonly valueType: IType; describe(): string; isAssignableFrom(type: IType): boolean; isValidSnapshot(value: any, context: IContext): IValidationResult; } export declare class IdentifierReferenceType extends BaseReferenceType { readonly shouldAttachNode: boolean; constructor(targetType: IType); getValue(node: INode): any; getSnapshot(node: INode): any; instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: any): INode; reconcile(current: INode, newValue: any): INode; } export declare class CustomReferenceType extends BaseReferenceType { private readonly referOptions; readonly shouldAttachNode: boolean; constructor(targetType: IType, referOptions: ReferenceOptions); getValue(node: INode): T; getSnapshot(node: INode): any; instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: any): INode; reconcile(current: INode, snapshot: any): INode; } export declare type ReferenceOptions = { get(identifier: string | number, parent: IStateTreeNode | null): T; set(value: T, parent: IStateTreeNode | null): string | number; }; export declare function reference(factory: IType, options?: ReferenceOptions): IType; export declare function isReferenceType(type: any): type is BaseReferenceType;