@types/makeerror
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Installation

npm install --save @types/makeerror

Summary

This package contains type definitions for makeerror (https://github.com/daaku/nodejs-makeerror#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/makeerror.

index.d.ts

export = makeError;

declare function makeError<T extends makeError.DefaultData>(
    name: string,
    defaultMessage?: string,
    defaultData?: T,
): makeError.CustomErrorConstructor<T>;

declare namespace makeError {
    type DefaultData = Record<string, unknown> & { proto?: CustomError<Record<string, unknown>> };

    interface CustomErrorConstructor<T extends Record<string, unknown>> {
        new<U, V>(
            message?: U extends Record<string, unknown> ? U : string,
            data?: V extends Record<string, unknown> ? V : never,
        ): U extends Record<string, unknown> ? V extends Record<string, unknown> ? CustomError<V>
            : CustomError<U>
            : V extends Record<string, unknown> ? CustomError<V>
            : CustomError<T>;

        <U, V>(
            message?: U extends Record<string, unknown> ? U : string,
            data?: V extends Record<string, unknown> ? V : never,
        ): U extends Record<string, unknown> ? V extends Record<string, unknown> ? CustomError<V>
            : CustomError<U>
            : V extends Record<string, unknown> ? CustomError<V>
            : CustomError<T>;

        readonly prototype: "proto" extends keyof T ? T["proto"] : BaseError;
    }

    interface CustomError<T extends Record<string, unknown>> extends BaseError {
        data: DataObject<T>;
        fileName?: string;
        lineNumber?: number;
    }
}

type DataObject<T extends Record<string, unknown>> = {
    [P in keyof T as Exclude<P, "proto">]: T[P];
};

interface BaseError extends Error {
    toString(): string;
}

Additional Details

  • Last updated: Tue, 07 Nov 2023 09:09:39 GMT
  • Dependencies: none

Credits

These definitions were written by yutak23.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/makeerror

Weekly Downloads

10,093

Version

1.0.3

License

MIT

Unpacked Size

5.69 kB

Total Files

5

Last publish

Collaborators

  • types