You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.d.ts 947B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Create a new error constructor instance.
  3. */
  4. declare function makeError(
  5. name: string
  6. ): makeError.Constructor<makeError.BaseError>;
  7. /**
  8. * Set the constructor prototype to `BaseError`.
  9. */
  10. declare function makeError<T extends Error>(super_: {
  11. new (...args: any[]): T;
  12. }): makeError.Constructor<T & makeError.BaseError>;
  13. /**
  14. * Create a specialized error instance.
  15. */
  16. declare function makeError<T extends Error, K>(
  17. name: string | Function,
  18. super_: K
  19. ): K & makeError.SpecializedConstructor<T>;
  20. declare namespace makeError {
  21. /**
  22. * Use with ES2015+ inheritance.
  23. */
  24. export class BaseError extends Error {
  25. message: string;
  26. name: string;
  27. stack: string;
  28. constructor(message?: string);
  29. }
  30. export interface Constructor<T> {
  31. new (message?: string): T;
  32. super_: any;
  33. prototype: T;
  34. }
  35. export interface SpecializedConstructor<T> {
  36. super_: any;
  37. prototype: T;
  38. }
  39. }
  40. export = makeError;