import type { BaseNode } from 'estree'; import { RuntimeSourceError } from './base'; /** * A specific {@link RuntimeSourceError} that is thrown when a function receives a parameter of the wrong type. * * @example * ``` * function play_sound(sound: unknown): asserts sound is Sound { * if (!is_sound(sound)) { * throw new InvalidParameterTypeError('Sound', sound, play_sound.name, 'sound'); * } * } * ``` */ export declare class InvalidParameterTypeError extends RuntimeSourceError { /** * String representation of the expected type. Examples include "number", "string", or "Point". */ readonly expectedType: string; /** * The actual value that was received. */ readonly actualValue: unknown; /** * The name of the function that received the invalid parameter. */ readonly func_name: string; /** * The name of the parameter that received the invalid value, if available. */ readonly param_name?: string | undefined; constructor( /** * String representation of the expected type. Examples include "number", "string", or "Point". */ expectedType: string, /** * The actual value that was received. */ actualValue: unknown, /** * The name of the function that received the invalid parameter. */ func_name: string, /** * The name of the parameter that received the invalid value, if available. */ param_name?: string | undefined, node?: BaseNode); explain(): string; } /** * A subclass of the {@link InvalidParameterTypeError} that is thrown when a function receives a callback parameter * that is not a function or does not have the expected number of parameters. * * @example * ``` * function call_callback(callback: (x: number, y: number) => number) { * if (!isFunctionOfLength(callback, 2)) { * throw new InvalidCallbackError(2, callback, call_callback.name, 'callback'); * } * } * ``` */ export declare class InvalidCallbackError extends InvalidParameterTypeError { constructor( /** * Either the expected number of parameters of the callback function, or a string describing the expected callback type. */ expected: number | string, actualValue: unknown, func_name: string, param_name?: string, node?: BaseNode); } export interface InvalidNumberParameterErrorOptions { /** * Maximum allowable value (inclusive). Set to `undefined` to not perform a maximum check. */ max?: number; /** * Minimum allowable value (inclusive). Set to `undefined` to not perform a minimum check. */ min?: number; /** * `true` by default. Set to `false` to allow non integer values */ integer?: boolean; } /** * Subclass of {@link InvalidParameterTypeError} intended for * use with numeric values */ export declare class InvalidNumberParameterError extends InvalidParameterTypeError { constructor(value: unknown, options: InvalidNumberParameterErrorOptions | string, func_name: string, param_name?: string, node?: BaseNode); }