Skip to content

Commit

Permalink
Support optionless function (#6)
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
mcollina committed Apr 7, 2023
1 parent 875d988 commit 8bbc8ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
24 changes: 16 additions & 8 deletions index.d.ts
Expand Up @@ -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
export = closeWithGrace
10 changes: 9 additions & 1 deletion index.test-d.ts
Expand Up @@ -71,4 +71,12 @@ expectType<{
expectType<{
close: () => void
uninstall: () => void
}>(closeWithGrace({ delay: 100 }, AllCallback))
}>(closeWithGrace({ delay: 100 }, AllCallback))

closeWithGrace({ delay: 100 }, async function ({ err }) {
expectType<Error | undefined>(err)
})

closeWithGrace(async function ({ err }) {
expectType<Error | undefined>(err)
})

0 comments on commit 8bbc8ed

Please sign in to comment.