From 8d0a457e068a6886e2e4b56287ec948a18e96774 Mon Sep 17 00:00:00 2001 From: CheerlessCloud Date: Sun, 20 Jun 2021 12:54:24 +0300 Subject: [PATCH] feat: add typescript declarations BREAKING CHANGES: due to usage of unknown types it may introduce breaking changes in legacy typescript projects with own typings. --- .eslintignore | 1 + index.d.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 index.d.ts diff --git a/.eslintignore b/.eslintignore index d12992c..e8e690f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -12,3 +12,4 @@ typings/ dist .idea/ .vscode/ +index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..fa10106 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,17 @@ +export = EError + +declare class EError extends Error { + [prop: string]: unknown; + + public combine(fields: Record): EError + public wrap>(error: TError): TError & { [prop: string]: unknown } + + public static wrap>(error: TError, fields: Record): TError & { [prop: string]: unknown } + + public static prepare(baseClass: EErrorClass, fields: Record): EErrorClass + public static prepare(fields: Record): EErrorClass +} + +declare interface EErrorClass { + new (message?: string): EError; +}