/** * 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`. */ export declare type Defined = Exclude; /** * `PropChainObjectWrapper` gives TypeScript visibility into the properties of * an `PropChainType` object at compile-time. */ export declare type PropChainObjectWrapper = { [K in keyof T]-?: PropChainType; }; /** * Data accessor interface to dereference the value of the `TSOCType`. */ export interface PropChainDataAccessor { /** * Data accessor without a default value. If no data exists, * `undefined` is returned. */ >(callback: Callback): PropChainOnFinish; } /** * `PropChainArrayWrapper` gives TypeScript visibility into the `PropChainType` 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 PropChainArrayWrapper> { length: PropChainType; [K: number]: PropChainType; } /** * Data accessor interface to dereference the value of an `any` type. * @extends PropChainDataAccessor */ export interface PropChainAny extends PropChainDataAccessor { [K: string]: PropChainAny; } /** * `PropChainDataWrapper` selects between `PropChainArrayWrapper`, `PropChainObjectWrapper`, and `PropChainDataAccessor` * to wrap Arrays, Objects and all other types respectively. */ export declare type PropChainDataWrapper = 0 extends 1 & T ? PropChainAny & PropChainDataAccessor : T extends any[] ? PropChainArrayWrapper : T extends object ? PropChainObjectWrapper : PropChainDataAccessor; /** * An object that supports optional chaining */ export declare type PropChainType = PropChainDataAccessor & PropChainDataWrapper>; export declare type PropChainCallback = (getter: (state: S) => T, keyPath: Array) => any; /** * Callback returned by prop-chain */ export declare type PropChainOnFinish> = ReturnType extends (...args: infer P) => infer R ? (...args: P) => R : never; export declare function continuePropertyChain(state: S, data: T, keyPath?: Array): PropChainType; /** * Start a new prop chain of the type specified * * @param state */ export declare function propertyChain(state?: S): PropChainType;