import type { StateSignal } from "../../signals/types/index.js"; type IsNullish = Extract extends never ? false : true; interface PathCallRequired { (): T; } interface PathCallOptional { (): T | undefined; (initialValue: I): Exclude | I; } /** * Optional-chaining semantics: a segment is "optional" if any ancestor on the * path may be null/undefined/missing. Index access into arrays is always * optional (out-of-bounds), regardless of the user's tsconfig. */ type PathChildren = T extends Map | Set ? unknown : T extends readonly (infer E)[] ? { readonly [index: number]: PathNode; } : T extends object ? { readonly [K in keyof T]-?: PathNode>; } : unknown; export type PathNode = (TOptional extends true ? PathCallOptional : PathCallRequired) & PathChildren, TOptional extends true ? true : IsNullish>; export interface ProxyStateSignal extends StateSignal { mutate(recipe: (draft: T) => void, actionName?: string): void; readonly root: PathNode; } export {};