import { Brand, Result } from '../base'; import { ConstraintOptions, ConversionErrorFormatter, Converter, ConverterTraits, DefaultingConverter, OnError } from './converter'; /** * internal */ type InnerInferredType = TCONV extends Converter ? TTO extends Array ? InnerInferredType[] : TTO : TCONV extends Array ? InnerInferredType[] : TCONV; /** * Infers the type that will be returned by an instantiated converter. Works * for complex as well as simple types. * @example `Infer` is `Map` * @beta */ export type Infer = TCONV extends Converter ? InnerInferredType : never; /** * Deprecated name for Infer retained for compatibility * @deprecated use @see Infer instead * @internal */ export type ConvertedToType = Infer; /** * Function signature for a converter function. * @public */ export type ConverterFunc = (from: unknown, self: Converter, context?: TC) => Result; /** * Base templated wrapper to simplify creation of new {@link Converter}s. * @public */ export declare class BaseConverter implements Converter { /** * @internal */ protected readonly _defaultContext?: TC; /** * @internal */ protected _isOptional: boolean; /** * @internal */ protected _brand?: string; private readonly _converter; /** * Constructs a new {@link Converter} which uses the supplied function to perform the conversion. * @param converter - The conversion function to be applied. * @param defaultContext - Optional conversion context to be used by default. * @param traits - Optional {@link Conversion.ConverterTraits | traits} to be assigned to the resulting * converter. */ constructor(converter: ConverterFunc, defaultContext?: TC, traits?: ConverterTraits); /** * {@inheritdoc Converter.isOptional} */ get isOptional(): boolean; /** * {@inheritdoc Converter.brand} */ get brand(): string | undefined; /** * {@inheritdoc Converter.convert} */ convert(from: unknown, context?: TC): Result; /** * {@inheritdoc Converter.convertOptional} */ convertOptional(from: unknown, context?: TC, onError?: OnError): Result; /** * {@inheritdoc Converter.optional} */ optional(onError?: OnError): Converter; /** * {@inheritdoc Converter.map} */ map(mapper: (from: T, context?: TC) => Result): Converter; /** * {@inheritdoc Converter.mapConvert} */ mapConvert(mapConverter: Converter): Converter; /** * {@inheritdoc Converter.mapItems} */ mapItems(mapper: (from: unknown, context?: TC) => Result): Converter; /** * {@inheritdoc Converter.mapConvertItems} */ mapConvertItems(mapConverter: Converter): Converter; /** * {@inheritdoc Converter.withAction} */ withAction(action: (result: Result, context?: TC) => Result): Converter; /** * {@inheritdoc Converter.withTypeGuard} */ withTypeGuard(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter; /** * {@inheritdoc Converter.withItemTypeGuard} */ withItemTypeGuard(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter; /** * {@inheritdoc Converter.withConstraint} */ withConstraint(constraint: (val: T, context?: TC) => boolean | Result, options?: ConstraintOptions): Converter; /** * {@inheritdoc Converter.withBrand} */ withBrand(brand: B): Converter, TC>; /** * {@inheritdoc Converter.withDefault} */ withDefault(defaultValue: TD): DefaultingConverter; /** * @internal */ protected _context(supplied?: TC): TC | undefined; /** * {@inheritdoc Converter.withFormattedError} */ withFormattedError(formatter: ConversionErrorFormatter): Converter; /** * @internal */ protected _traits(traits?: Partial): ConverterTraits; /** * @internal */ protected _with(traits: Partial): this; } export {}; //# sourceMappingURL=baseConverter.d.ts.map