ts-flex-query
Version:
Flexible and type-safe data queries
19 lines (18 loc) • 1.4 kB
TypeScript
import { Expression } from '../../core';
import { PipeOperator } from '../../core/pipe-operator';
import { ObjectValueSelector, ObjectValueSelectorType } from '../../helpers/object-value-selector';
/** Applies the given operator if the input is defined. Otherwise, the input value (null or undefined) is propagated. */
export declare function letIfDefined<TIn, TOut>(selector: PipeOperator<NonNullable<NoInfer<TIn>>, TOut>): PipeOperator<TIn, TOut | (TIn & (null | undefined))>;
/** Applies the given selector if the input is defined. Otherwise, the input value (null or undefined) is propagated. */
export declare function letIfDefined<TIn, TSelector extends ObjectValueSelector<NonNullable<TIn>>>(selector: TSelector): PipeOperator<TIn, ObjectValueSelectorType<NonNullable<TIn>, TSelector> | (TIn & (null | undefined))>;
interface DefinedCheckResult {
/** The input expression which is checked to be defined. */
baseExpression: Expression;
/** The symbol which is used to access the defined base expression value in the @see body. */
baseExpressionVariableSymbol: symbol;
/** The body expression which is only evaluated if @see baseExpression is defined. */
body: Expression;
}
/** Unwraps an expression which was created using the @see letIfDefined operator. */
export declare function unwrapLetIfDefined(expression: Expression): DefinedCheckResult | undefined;
export {};