From cfbe9c05a5b3de542f195d4fbe7baeec3092d120 Mon Sep 17 00:00:00 2001 From: segayuu Date: Tue, 22 May 2018 18:47:07 +0900 Subject: [PATCH] When err is undefined, fail is not executed --- types/iferr/iferr-tests.ts | 2 +- types/iferr/index.d.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/iferr/iferr-tests.ts b/types/iferr/iferr-tests.ts index f7377358cf..ce1bea725e 100644 --- a/types/iferr/iferr-tests.ts +++ b/types/iferr/iferr-tests.ts @@ -7,7 +7,7 @@ const { tiferr, throwerr, printerr } = iferr; const { readFile } = fs; -const errcb = (err: Error | undefined) => { throw err; }; +const errcb = (err: Error) => { throw err; }; readFile("test.txt", iferr(errcb, result => { Buffer.from("test", "utf8") === result; diff --git a/types/iferr/index.d.ts b/types/iferr/index.d.ts index c65c270b49..0b40866559 100644 --- a/types/iferr/index.d.ts +++ b/types/iferr/index.d.ts @@ -7,15 +7,15 @@ type nodeCallback = (err: Error | undefined, ...a: T[]) => any; // Delegates to `succ` on sucecss or to `fail` on error // ex: Thing.load(123, iferr(cb, thing => ...)) -declare function iferr(fail: (err: Error | undefined) => void, succ: (...result: T[]) => void): nodeCallback; +declare function iferr(fail: (err: Error) => void, succ: (...result: T[]) => void): nodeCallback; declare namespace iferr { // Delegates to `succ` on sucecss or to `fail` on error // ex: Thing.load(123, iferr(cb, thing => ...)) - function iferr(fail: (err: Error | undefined) => void, succ: (...result: T[]) => void): nodeCallback; + function iferr(fail: (err: Error) => void, succ: (...result: T[]) => void): nodeCallback; // Like iferr, but also catches errors thrown from `succ` and passes to `fail` - function tiferr(fail: (err: Error | undefined) => void, succ: (...result: T[]) => void): nodeCallback; + function tiferr(fail: (err: Error) => void, succ: (...result: T[]) => void): nodeCallback; // Delegate to the success function on success, throws the error otherwise // ex: Thing.load(123, throwerr(thing => ...))