From dfd4a7a859447bf05fcad1fee8c41b584d780004 Mon Sep 17 00:00:00 2001 From: Retsam Date: Thu, 26 Dec 2019 14:50:34 -0500 Subject: [PATCH] s3rver: make error optional in callback signature (#40974) * s3rver: make error potentially null in callback signature * s3rver: returns itself when run is called with a callback * Add signature for close method --- types/s3rver/index.d.ts | 9 +++++---- types/s3rver/s3rver-tests.ts | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/types/s3rver/index.d.ts b/types/s3rver/index.d.ts index c417aefab6..49ad8e3822 100644 --- a/types/s3rver/index.d.ts +++ b/types/s3rver/index.d.ts @@ -7,9 +7,6 @@ /// - -import * as http from "http"; - declare class S3rver { constructor(options: S3rverOptions) setPort(port: number): S3rver; @@ -18,8 +15,12 @@ declare class S3rver { setSilent(silent: boolean): S3rver; setIndexDocument(indexDocument: string): S3rver; setErrorDocument(errorDocument: string): S3rver; - run(callback: (error: Error, hostname: string, port: number, directory: string) => void): http.Server; + run(callback: (error: Error | null, hostname: string, port: number, directory: string) => void): S3rver; run(): Promise; + close(): Promise; + // Should return S3rver, but doesn't in all cases, currently + // See https://github.com/jamhall/s3rver/pull/571 + close(callback: (error: Error | null) => void): void; } interface S3rverOptions { diff --git a/types/s3rver/s3rver-tests.ts b/types/s3rver/s3rver-tests.ts index 8e565ef14b..efd68514eb 100644 --- a/types/s3rver/s3rver-tests.ts +++ b/types/s3rver/s3rver-tests.ts @@ -10,6 +10,7 @@ var s3rver = new S3rver({ }).run((err, hostname, port, directory) => {}); s3rver.close(); +s3rver.close(e => console.log(e)); // using new options import fs = require('fs');