From 8bbc8edd6e0387a04b28c9b508bce17f2b64fb71 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Fri, 7 Apr 2023 12:14:18 +0200 Subject: [PATCH] Support optionless function (#6) Signed-off-by: Matteo Collina --- index.d.ts | 24 ++++++++++++++++-------- index.test-d.ts | 10 +++++++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index 6cafda6..c9fea9f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -47,16 +47,24 @@ import * as closeWithGrace from 'close-with-grace' }) */ declare function closeWithGrace ( - opts: - | closeWithGrace.CloseWithGraceAsyncCallback - | closeWithGrace.CloseWithGraceCallback - | closeWithGrace.Options + fn: closeWithGrace.CloseWithGraceAsyncCallback +): CloseWithGraceReturn +declare function closeWithGrace ( + fn: closeWithGrace.CloseWithGraceCallback +): CloseWithGraceReturn +declare function closeWithGrace ( + opts: closeWithGrace.Options, + fn: closeWithGrace.CloseWithGraceAsyncCallback ): CloseWithGraceReturn declare function closeWithGrace ( opts: closeWithGrace.Options, - fn?: - | closeWithGrace.CloseWithGraceAsyncCallback - | closeWithGrace.CloseWithGraceCallback + fn: closeWithGrace.CloseWithGraceCallback +): CloseWithGraceReturn +declare function closeWithGrace ( + fn: closeWithGrace.CloseWithGraceAsyncCallback +): CloseWithGraceReturn +declare function closeWithGrace ( + fn: closeWithGrace.CloseWithGraceCallback ): CloseWithGraceReturn -export = closeWithGrace \ No newline at end of file +export = closeWithGrace diff --git a/index.test-d.ts b/index.test-d.ts index 9888749..3f86ef3 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -71,4 +71,12 @@ expectType<{ expectType<{ close: () => void uninstall: () => void -}>(closeWithGrace({ delay: 100 }, AllCallback)) \ No newline at end of file +}>(closeWithGrace({ delay: 100 }, AllCallback)) + +closeWithGrace({ delay: 100 }, async function ({ err }) { + expectType(err) +}) + +closeWithGrace(async function ({ err }) { + expectType(err) +})