diff --git a/README.md b/README.md index ad7f2ce..f4cef0f 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ throw err; Simple usage. ```js +// JavaScript var errcode = require('err-code'); // fill error with message + code @@ -55,6 +56,17 @@ throw errcode(new Error('My message'), 'ESOMECODE', { detail: 'Additional inform throw errcode(new Error('My message'), { detail: 'Additional information about the error' }); ``` +```typescript +// TypeScript +import errcode = require('err-code'); + +// fill error with message + code +throw errcode(new Error('My message'), 'ESOMECODE'); +// fill error with message + code + props +throw errcode(new Error('My message'), 'ESOMECODE', { detail: 'Additional information about the error' }); +// fill error with message + props +throw errcode(new Error('My message'), { detail: 'Additional information about the error' }); +``` ## Tests diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..b2ce72a --- /dev/null +++ b/index.d.ts @@ -0,0 +1,10 @@ +type Scalar = Exclude + +declare function createError(error: E, code: C, props?: T): E & T & { code: C } +declare function createError(error: E, props?: T): E & T + +declare namespace createError { + +} + +export = createError