Skip to content

Commit

Permalink
feat: add ts typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Dec 18, 2020
1 parent 7f2a9b9 commit 4823e18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export type Scalar = number | string | boolean | bigint | null | undefined;
export interface Err<Code extends Scalar, Ext extends Object> extends Error, Ext {
code: Code
}

interface CreateError {
<Code extends Scalar, Ext extends Object> (
reason:string|Error,
code:Code,
ext:Ext
):Err<Code, Ext>
<Code extends Scalar> (reason:string|Error, code:Code):Err<Code, {}>
}

declare var createError:CreateError
exports = createError
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.0.3",
"description": "Create an error with a code",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"lint": "eslint '{*.js,test/**/*.js}' --ignore-pattern *.umd.js",
"test": "mocha --bail",
Expand Down

0 comments on commit 4823e18

Please sign in to comment.