import type { State } from "../reducers"; import type { Selector } from "./SelectorTypes"; import type { ObservableStore } from "../store/ObservableStore"; /** * `SelectorChainObjectWrapper` gives TypeScript visibility into the properties of * an `SelectorChainType` object at compile-time. */ declare type SelectorChainObjectWrapper = { [K in keyof T]-?: SelectorChainType; }; /** * Data accessor interface to dereference the value of the `TSOCType`. */ /** * `SelectorChainArrayWrapper` gives TypeScript visibility into the `SelectorChainType` values of an array * without exposing Array methods (it is problematic to attempt to invoke methods during * the course of an optional chain traversal). */ export interface SelectorChainArrayWrapper> { length: SelectorChainType; [K: number]: SelectorChainType; } /** * Data accessor interface to dereference the value of an `any` type. * @extends SelectorChainDataAccessor */ export interface SelectorChainAny extends SelectorChainDataAccessor { [K: string]: SelectorChainAny; } /** * `SelectorChainDataWrapper` selects between `SelectorChainArrayWrapper`, `SelectorChainObjectWrapper`, and `SelectorChainDataAccessor` * to wrap Arrays, Objects and all other types respectively. */ export declare type SelectorChainDataWrapper = 0 extends (1 & T) ? (SelectorChainAny & SelectorChainDataAccessor) : T extends any[] ? SelectorChainArrayWrapper : T extends object ? SelectorChainObjectWrapper : SelectorChainDataAccessor; export declare type SelectorChainType = (SelectorChainDataAccessor & SelectorChainDataWrapper>); export declare type SelectorChainOnFinish> = ReturnType extends ((...args: infer P) => (infer R)) ? ((...args: P) => R) : never; export interface SelectorChainDataAccessor { (): Selector; } export interface SelectorChainCallback { (getter: (state: S) => T, keyPath: Array): SelectorChainDataAccessor; } export declare type SelectorChain = SelectorChainType; export declare function selectorChain(store: ObservableStore, state: S): SelectorChain; export {};