From f6a11590cfcf906af4b04a297626f6d87201a73e Mon Sep 17 00:00:00 2001 From: CiriousJoker Date: Tue, 26 Jun 2018 07:04:06 +0200 Subject: [PATCH] Fixed typing for non-promises & added err typing Function works with thenable non-promises and returns an Error or a custom error type --- src/await-to-js.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/await-to-js.ts b/src/await-to-js.ts index ea0ce3c..c6b8f3b 100644 --- a/src/await-to-js.ts +++ b/src/await-to-js.ts @@ -3,13 +3,13 @@ * @param { Object= } errorExt - Additional Information you can pass to the err object * @return { Promise } */ -export function to( - promise: Promise, +export function to( + promise: any, errorExt?: object ): Promise<[U | null, T | undefined]> { return promise - .then<[null, T]>((data: T) => [null, data]) - .catch<[U, undefined]>(err => { + .then((data: T) => [null, data]) + .catch((err: U) => { if (errorExt) { Object.assign(err, errorExt) }