Skip to content

Commit

Permalink
Merge pull request #21 from CiriousJoker/patch-1
Browse files Browse the repository at this point in the history
Fixed typing for non-promises & added err typing
  • Loading branch information
scopsy authored Nov 21, 2018
2 parents 28f7b25 + f6a1159 commit 6c25d6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/await-to-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* @param { Object= } errorExt - Additional Information you can pass to the err object
* @return { Promise }
*/
export function to<T, U = any>(
promise: Promise<T>,
export function to<T, U = Error>(
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)
}
Expand Down

0 comments on commit 6c25d6a

Please sign in to comment.