import { State } from "../reducers"; /** * Copyright (C) 2019-present, Rimeto, LLC. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /** * A generic type that cannot be `undefined`. */ declare type Defined = Exclude; /** * `SelectorChainObjectWrapper` gives TypeScript visibility into the properties of * an `SelectorChainType` object at compile-time. */ declare type SelectorChainObjectWrapper, T> = { [K in keyof T]-?: SelectorChainType; }; /** * Data accessor interface to dereference the value of the `TSOCType`. */ export interface SelectorChainDataAccessor, T> { /** * Data accessor without a default value. If no data exists, * `undefined` is returned. */ (noDefaultValue?: undefined): Defined | undefined; /** * Data accessor with default value. */ (defaultValue: NonNullable): NonNullable; (nullDefaultValue: T extends null ? null : never): Defined; } /** * `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, T> { 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, T> = 0 extends (1 & T) ? SelectorChainAny : T extends any[] ? SelectorChainArrayWrapper : T extends object ? SelectorChainObjectWrapper : SelectorChainDataAccessor; /** * An object that supports optional chaining */ export declare type SelectorChainType, T> = SelectorChainDataAccessor & SelectorChainDataWrapper>; /** * Optional chaining with default values. To inspect a property value in * a tree-like structure, invoke it as a function, optionally passing a default value. * * @example * // Given: * const x = oc({ * a: 'hello', * b: { d: 'world' }, * c: [-100, 200, -300], * }); * * // Then: * x.a() === 'hello' * x.b.d() === 'world' * x.c[0]() === -100 * x.c[100]() === undefined * x.c[100](1234) === 1234 * x.c.map((e) => e()) === [-100, 200, -300] * x.d.e() === undefined * x.d.e('optional default value') === 'optional default value' * (x as any).y.z.a.b.c.d.e.f.g.h.i.j.k() === undefined */ export declare function selector, T>(data?: T): SelectorChainType; export {};