Skip to content

Commit bfe66aa

Browse files
committed
Add types export.
1 parent 2338cb3 commit bfe66aa

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export class ApplicationError extends Error {
2+
code: string;
3+
stack: string;
4+
message: object;
5+
constructor(message: object, code?: string);
6+
}

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
let originalError = Error;
20-
class ApplicationError extends Error {
20+
class ApplicationErrorExtension extends Error {
2121
constructor(message, rawCode, ...args) {
2222
const code = rawCode || typeof message === 'string' && message || typeof message === 'object' && message.code || null;
2323

@@ -51,12 +51,12 @@ class ApplicationError extends Error {
5151
}
5252
}
5353

54-
const originalApplicationErrorClass = ApplicationError;
55-
const ApplicationErrorWrapper = function(...args) { return new originalApplicationErrorClass(...args); };
54+
const originalApplicationErrorClass = ApplicationErrorExtension;
55+
const ApplicationError = function(...args) { return new originalApplicationErrorClass(...args); };
5656
if (typeof global !== 'undefined') {
57-
global.ApplicationError = ApplicationErrorWrapper;
57+
global.ApplicationError = ApplicationError;
5858
}
59-
module.exports = ApplicationErrorWrapper;
59+
module.exports = ApplicationError;
6060

6161
/* eslint-disable no-extend-native */
6262
Error.create = function(errorObject, code) {

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
"version": "0.0.0",
44
"description": "Replace your lame string errors with object versions.",
55
"main": "index.js",
6+
"types": "index.d.ts",
67
"files": [
7-
"index.js"
8+
"index.js",
9+
"index.d.ts"
810
],
911
"scripts": {
1012
"lint": "eslint --ext .js tests index.js",

0 commit comments

Comments
 (0)