export type AnyErrorClassConstructor = new (...args: any[]) => Error; export type SpecificErrorClassConstructor = new (...args: any[]) => Error & ErrorInstance; /** * An internal symbol used to track class metadata. */ export declare const $kind: unique symbol; /** * Additional properties exposed as static properties of named error classes. */ export type NamedErrorConstructorStaticProperties = { /** * A reference to this class's `isX` function originally returned by * {@link makeNamedError}. */ isError: (parameter: unknown) => parameter is Error & ErrorInstance; }; /** * Returns `true` if `parameter` is _an instance of_ an {@link Error} subclass * created using {@link makeNamedError}. */ export declare function isANamedErrorInstance(parameter: unknown): parameter is Error; /** * Returns `true` if `parameter` is an {@link Error} subclass (_not an * instance_) created using {@link makeNamedError}. * * **This function is NOT for match instances, but actual classes extending * {@link Error}!** */ export declare function isANamedErrorClass(parameter: unknown): parameter is AnyErrorClassConstructor & NamedErrorConstructorStaticProperties; /** * This function accepts a class extending {@link Error} and assigns it a name * that will survive minification/transpilation, improving DX. * * Along with the error itself, this function returns the `is${name}` helper * function and the `$kind_${name}` symbol, both of which can be used to * identify instances of the class without resorting to `instanceof`, which has * some caveats (e.g. realms). * * Note that all errors will have a non-own "name" property injected into their * prototype chain for improved DX. */ export declare function makeNamedError(ErrorClass: ErrorClass, name: Name): { [key in `$kind_${Name}`]: symbol } & { [key in Name]: SpecificErrorClassConstructor> & NamedErrorConstructorStaticProperties> } & { [key in `is${Name}`]: (parameter: unknown) => parameter is InstanceType };