import { TypeFromTypeId, TypeId } from "../types/typeId"; export interface ArgumentErrorOptions extends ErrorOptions { /** name of the parameter that causes this exception. */ paramName?: string; /** 0-based index of the parameter that causes this exception. */ paramIndex?: number; } /** * Represents common information shared between {@link ArgumentTypeError} and {@link ArgumentRangeError}. */ export interface ArgumentError extends Error { /** name of the parameter that causes this exception. */ readonly paramName?: string; /** 0-based index of the parameter that causes this exception. */ readonly paramIndex?: number; } /** * The error that is thrown when one of the arguments provided to a method is not valid. */ export declare class ArgumentRangeError extends RangeError implements ArgumentError { name: string; /** name of the parameter that causes this exception. */ readonly paramName?: string; /** 0-based index of the parameter that causes this exception. */ readonly paramIndex?: number; constructor(message?: string, options?: ArgumentErrorOptions); static create(paramIndex: number | undefined, paramName?: string, message?: string): ArgumentRangeError; } export interface ArgumentTypeErrorOptions extends ArgumentErrorOptions { valueType?: TypeId; argumentTypes?: TypeId[]; } /** * The error that is thrown when one of the arguments provided to a method is not valid. */ export declare class ArgumentTypeError extends TypeError implements ArgumentError { name: string; /** name of the parameter that causes this exception. */ readonly paramName?: string; /** 0-based index of the parameter that causes this exception. */ readonly paramIndex?: number; readonly valueType?: TypeId; readonly targetType?: TypeId; constructor(message?: string, options?: ArgumentTypeErrorOptions); /** * Short-hand function to create an {@link ArgumentTypeError} instace with general message. * * @see {@link checkArgumentType} */ static create(paramIndex: number | undefined, paramName?: string, message?: string): ArgumentRangeError; } /** * The error that is thrown when a `null` (or `undefined`) value is passed to a method that does not accept it as a valid argument. * * @remarks By convention of jscorlib, we recommend not distinguishing between `null` and `undefined`. */ export declare class ArgumentNullError extends ArgumentTypeError { name: string; constructor(message?: string, options?: ArgumentTypeErrorOptions); static create(paramIndex: number | undefined, paramName?: string, message?: string): ArgumentRangeError; } /** * A helper function to ensure the given argument value satisfies the type constraints. * @param paramIndex 0-based index of the parameter. * @param paramName parameter name. * @param value passed in parameter value. * @param allowedType any allowed types of this parameter. * * @throws {ArgumentTypeError} Provided parameter does not satisfy the type constraints. */ export declare function checkArgumentType(paramIndex: number, paramName: string, value: unknown, ...allowedType: TTypeIds): asserts value is TypeFromTypeId; export declare function checkArgumentType(paramIndex: number, paramName: string, value: unknown, ...allowedTypes: TypeId[]): void; //# sourceMappingURL=argumentErrors.d.ts.map