mobx-bonsai
    Preparing search index...

    Type Alias BaseNodeType<TNode, TCapabilities, TOptional, TKey, TOther>

    BaseNodeType: {
        _extendsKeys: Set<string>;
        defaultGenerators?: { [K in keyof TNode]?: () => TNode[K] };
        actions<
            TActions extends Record<string, (this: TNode, ...args: any[]) => any>,
        >(
            actions: TActions,
        ): BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: PrependArgument<TActions[k], TNode>
                        },
                    > & {
                        [Key in string
                        | number
                        | symbol as Key extends keyof OmitIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: PrependArgument<TActions[k], TNode>
                        },
                    >
                )[KeyType]
            },
        >;
        computeds<TComputeds extends Record<string, ComputedEntry<TNode, any>>>(
            computeds: TComputeds,
        ): BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: TComputeds[k] extends () => any
                                ? PrependArgument<any[any], TNode>
                                : (...)[(...)] extends ComputedFnWithOptions<(...), (...)>
                                    ? PrependArgument<(...), (...)>
                                    : never
                        },
                    > & {
                        [Key in string
                        | number
                        | symbol as Key extends keyof OmitIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: TComputeds[k] extends () => any
                                ? PrependArgument<any[any], TNode>
                                : (...)[(...)] extends ComputedFnWithOptions<(...), (...)>
                                    ? PrependArgument<(...), (...)>
                                    : never
                        },
                    >
                )[KeyType]
            },
        >;
        defaults<TGen extends { [K in string | number | symbol]?: () => TNode[K] }>(
            defaultGenerators: TGen,
        ): BaseNodeType<
            TNode,
            TCapabilities,
            TOptional
            | keyof TGen & keyof TNode,
            TKey,
            TOther,
        >;
        extends<
            TExtendedNode extends object,
            TExtendedOptional extends string | number | symbol,
            TExtendedOther,
        >(
            nodeType: BaseNodeType<
                TExtendedNode,
                "untyped",
                TExtendedOptional,
                never,
                TExtendedOther,
            >,
        ): TNode extends TExtendedNode
            ? BaseNodeType<
                TNode<TNode>,
                TCapabilities,
                TOptional | TExtendedOptional,
                TKey,
                {
                    [KeyType in string | number | symbol]: (
                        {
                            [Key in string
                            | number
                            | symbol as Key extends keyof PickIndexSignature<(...)> ? never : Key]: PickIndexSignature<
                                TOther,
                            >[Key]
                        } & PickIndexSignature<TExtendedOther> & {
                            [Key in string | number | symbol as Key extends keyof OmitIndexSignature<
                                (...),
                            >
                                ? never
                                : Key]: OmitIndexSignature<TOther>[Key]
                        } & OmitIndexSignature<TExtendedOther>
                    )[KeyType]
                },
            >
            : never;
        getters<
            TGetters extends Record<string, (this: TNode, ...args: any[]) => any>,
        >(
            getters: TGetters,
        ): BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: PrependArgument<TGetters[k], TNode>
                        },
                    > & {
                        [Key in string
                        | number
                        | symbol as Key extends keyof OmitIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: PrependArgument<TGetters[k], TNode>
                        },
                    >
                )[KeyType]
            },
        >;
        settersFor<K extends string>(
            ...properties: readonly K[],
        ): BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            { [P in (...) as (...)]: (...) },
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<
                        {
                            [P in string as `set${Capitalize<P>}`]: (
                                node: TNode,
                                value: Readonly<(...)[(...)]>,
                            ) => void
                        },
                    > & {
                        [Key in string
                        | number
                        | symbol as Key extends keyof OmitIndexSignature<
                            { [P in (...) as (...)]: (...) },
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<
                        {
                            [P in string as `set${Capitalize<P>}`]: (
                                node: TNode,
                                value: Readonly<(...)[(...)]>,
                            ) => void
                        },
                    >
                )[KeyType]
            },
        >;
        snapshot(data: SetOptional<TNode, TOptional | TKey>): TNode;
        volatile<TVolatiles extends Record<string, () => any>>(
            volatile: TVolatiles,
        ): BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            VolatileAccessors<(...), (...)>,
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<VolatileAccessors<TVolatiles, TNode>> & {
                        [Key in string | number | symbol as Key extends keyof OmitIndexSignature<
                            VolatileAccessors<(...), (...)>,
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<VolatileAccessors<TVolatiles, TNode>>
                )[KeyType]
            },
        >;
        (data: SetOptional<TNode, TOptional | TKey>): TNode;
    } & (
        TCapabilities extends "typed"
        | "keyed"
            ? BaseNodeTypeWithType<TNode, TCapabilities, TOptional, TKey, TOther> & (
                TCapabilities extends "keyed"
                    ? BaseNodeTypeWithKey<TNode, TKey>
                    : unknown
            )
            : unknown
    ) & TOther

    Base node type definition with core functionality

    Type Parameters

    • TNode extends object

      Node structure that adheres to this type

    • TCapabilities extends "untyped" | "typed" | "keyed"

      Type of capabilities (untyped, typed or keyed)

    • TOptional extends keyof TNode

      Optional keys in the node structure

    • TKey extends keyof TNode | never

      Key field in the node structure (if any)

    • TOther

      Additional properties and methods

    Type declaration

    • _extendsKeys: Set<string>
    • OptionaldefaultGenerators?: { [K in keyof TNode]?: () => TNode[K] }

      Default generators defined so far.

    • actions: function
      • Registers action methods for nodes of this type

        Actions are methods that can modify the node state and are automatically wrapped in MobX actions for proper state tracking.

        Type Parameters

        • TActions extends Record<string, (this: TNode, ...args: any[]) => any>

          Record of action methods

        Parameters

        • actions: TActions

          An object of action methods

        Returns BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: PrependArgument<TActions[k], TNode>
                        },
                    > & {
                        [Key in string
                        | number
                        | symbol as Key extends keyof OmitIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: PrependArgument<TActions[k], TNode>
                        },
                    >
                )[KeyType]
            },
        >

        The same NodeType with added action methods that accept a node as their first parameter

    • computeds: function
      • Registers computed methods for nodes of this type

        Computed methods derive values from the node state and are automatically memoized by MobX for performance optimization.

        Type Parameters

        • TComputeds extends Record<string, ComputedEntry<TNode, any>>

          Record of computed properties

        Parameters

        • computeds: TComputeds

          Function that receives a node and returns an object of computed accessor methods

        Returns BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: TComputeds[k] extends () => any
                                ? PrependArgument<any[any], TNode>
                                : (...)[(...)] extends ComputedFnWithOptions<(...), (...)>
                                    ? PrependArgument<(...), (...)>
                                    : never
                        },
                    > & {
                        [Key in string
                        | number
                        | symbol as Key extends keyof OmitIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: TComputeds[k] extends () => any
                                ? PrependArgument<any[any], TNode>
                                : (...)[(...)] extends ComputedFnWithOptions<(...), (...)>
                                    ? PrependArgument<(...), (...)>
                                    : never
                        },
                    >
                )[KeyType]
            },
        >

        The same NodeType with added computed methods that accept a node as their first parameter

    • defaults: function
      • Define default values for keys in TOptional. When omitted, those properties are filled with the results of these generators.

        Type Parameters

        • TGen extends { [K in string | number | symbol]?: () => TNode[K] }

          Record of default value generators

        Parameters

        • defaultGenerators: TGen

        Returns BaseNodeType<
            TNode,
            TCapabilities,
            TOptional
            | keyof TGen & keyof TNode,
            TKey,
            TOther,
        >

    • extends: function
      • Extend this type from another untyped node type. The base node type can be a subset of the current node type.

        Type Parameters

        • TExtendedNode extends object
        • TExtendedOptional extends string | number | symbol
        • TExtendedOther

          Additional properties and methods from the base type

        Parameters

        • nodeType: BaseNodeType<TExtendedNode, "untyped", TExtendedOptional, never, TExtendedOther>

          Node type to extend from

        Returns TNode extends TExtendedNode
            ? BaseNodeType<
                TNode<TNode>,
                TCapabilities,
                TOptional | TExtendedOptional,
                TKey,
                {
                    [KeyType in string | number | symbol]: (
                        {
                            [Key in string
                            | number
                            | symbol as Key extends keyof PickIndexSignature<(...)> ? never : Key]: PickIndexSignature<
                                TOther,
                            >[Key]
                        } & PickIndexSignature<TExtendedOther> & {
                            [Key in string | number | symbol as Key extends keyof OmitIndexSignature<
                                (...),
                            >
                                ? never
                                : Key]: OmitIndexSignature<TOther>[Key]
                        } & OmitIndexSignature<TExtendedOther>
                    )[KeyType]
                },
            >
            : never

    • getters: function
      • Registers getter methods for nodes of this type

        Getters are methods that derive values from the node state without modifying it.

        Type Parameters

        • TGetters extends Record<string, (this: TNode, ...args: any[]) => any>

          Record of getter methods

        Parameters

        • getters: TGetters

          An object of getter methods

        Returns BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: PrependArgument<TGetters[k], TNode>
                        },
                    > & {
                        [Key in string
                        | number
                        | symbol as Key extends keyof OmitIndexSignature<
                            { [k in (...)]: (...) },
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<
                        {
                            [k in string
                            | number
                            | symbol]: PrependArgument<TGetters[k], TNode>
                        },
                    >
                )[KeyType]
            },
        >

        The same NodeType with added getter methods that accept a node as their first parameter

    • settersFor: function
      • Generates setter methods for specified properties

        Type Parameters

        • K extends string

        Parameters

        • ...properties: readonly K[]

          Names of properties to create setters for

        Returns BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            { [P in (...) as (...)]: (...) },
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<
                        {
                            [P in string as `set${Capitalize<P>}`]: (
                                node: TNode,
                                value: Readonly<(...)[(...)]>,
                            ) => void
                        },
                    > & {
                        [Key in string
                        | number
                        | symbol as Key extends keyof OmitIndexSignature<
                            { [P in (...) as (...)]: (...) },
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<
                        {
                            [P in string as `set${Capitalize<P>}`]: (
                                node: TNode,
                                value: Readonly<(...)[(...)]>,
                            ) => void
                        },
                    >
                )[KeyType]
            },
        >

        The same NodeType with added setter methods

    • snapshot: function
    • volatile: function
      • Adds volatile state properties to nodes of this type

        Volatile state is not persisted in snapshots and is local to each node instance.

        Type Parameters

        • TVolatiles extends Record<string, () => any>

          Record of volatile property getter functions

        Parameters

        • volatile: TVolatiles

          Object where each key defines a getter function for volatile state

        Returns BaseNodeType<
            TNode,
            TCapabilities,
            TOptional,
            TKey,
            {
                [KeyType in string
                | number
                | symbol]: (
                    {
                        [Key in string
                        | number
                        | symbol as Key extends keyof PickIndexSignature<
                            VolatileAccessors<(...), (...)>,
                        >
                            ? never
                            : Key]: PickIndexSignature<TOther>[Key]
                    } & PickIndexSignature<VolatileAccessors<TVolatiles, TNode>> & {
                        [Key in string | number | symbol as Key extends keyof OmitIndexSignature<
                            VolatileAccessors<(...), (...)>,
                        >
                            ? never
                            : Key]: OmitIndexSignature<TOther>[Key]
                    } & OmitIndexSignature<VolatileAccessors<TVolatiles, TNode>>
                )[KeyType]
            },
        >

        The same NodeType with added accessor methods for the volatile state