From e2e3f7d5dd17f15f12552dd3e07f09ba52761948 Mon Sep 17 00:00:00 2001 From: George Fu Date: Tue, 5 Dec 2023 12:37:58 -0500 Subject: [PATCH] align static create and ctor signatures for http handlers (#1093) --- .changeset/serious-otters-breathe.md | 6 ++++++ packages/fetch-http-handler/src/fetch-http-handler.ts | 6 ++++-- packages/node-http-handler/src/node-http-handler.ts | 4 +++- packages/node-http-handler/src/node-http2-handler.ts | 4 +++- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .changeset/serious-otters-breathe.md diff --git a/.changeset/serious-otters-breathe.md b/.changeset/serious-otters-breathe.md new file mode 100644 index 00000000000..e9f83eaf04b --- /dev/null +++ b/.changeset/serious-otters-breathe.md @@ -0,0 +1,6 @@ +--- +"@smithy/fetch-http-handler": patch +"@smithy/node-http-handler": patch +--- + +align ctor and static creation signatures for http handlers diff --git a/packages/fetch-http-handler/src/fetch-http-handler.ts b/packages/fetch-http-handler/src/fetch-http-handler.ts index cd9d48faae0..0beb2db9381 100644 --- a/packages/fetch-http-handler/src/fetch-http-handler.ts +++ b/packages/fetch-http-handler/src/fetch-http-handler.ts @@ -32,7 +32,9 @@ export class FetchHttpHandler implements HttpHandler { * @returns the input if it is an HttpHandler of any class, * or instantiates a new instance of this handler. */ - public static create(instanceOrOptions?: HttpHandler | FetchHttpHandlerConfig) { + public static create( + instanceOrOptions?: HttpHandler | FetchHttpHandlerOptions | Provider + ) { if (typeof (instanceOrOptions as any)?.handle === "function") { // is already an instance of HttpHandler. return instanceOrOptions as HttpHandler; @@ -41,7 +43,7 @@ export class FetchHttpHandler implements HttpHandler { return new FetchHttpHandler(instanceOrOptions as FetchHttpHandlerConfig); } - constructor(options?: FetchHttpHandlerOptions | Provider) { + constructor(options?: FetchHttpHandlerOptions | Provider) { if (typeof options === "function") { this.configProvider = options().then((opts) => opts || {}); } else { diff --git a/packages/node-http-handler/src/node-http-handler.ts b/packages/node-http-handler/src/node-http-handler.ts index 25c4243c279..ed3f7ee2ed3 100644 --- a/packages/node-http-handler/src/node-http-handler.ts +++ b/packages/node-http-handler/src/node-http-handler.ts @@ -34,7 +34,9 @@ export class NodeHttpHandler implements HttpHandler { * @returns the input if it is an HttpHandler of any class, * or instantiates a new instance of this handler. */ - public static create(instanceOrOptions?: HttpHandler | NodeHttpHandlerOptions) { + public static create( + instanceOrOptions?: HttpHandler | NodeHttpHandlerOptions | Provider + ) { if (typeof (instanceOrOptions as any)?.handle === "function") { // is already an instance of HttpHandler. return instanceOrOptions as HttpHandler; diff --git a/packages/node-http-handler/src/node-http2-handler.ts b/packages/node-http-handler/src/node-http2-handler.ts index 917f0697856..87d3d8e5cc3 100644 --- a/packages/node-http-handler/src/node-http2-handler.ts +++ b/packages/node-http-handler/src/node-http2-handler.ts @@ -53,7 +53,9 @@ export class NodeHttp2Handler implements HttpHandler { * @returns the input if it is an HttpHandler of any class, * or instantiates a new instance of this handler. */ - public static create(instanceOrOptions?: HttpHandler | NodeHttp2HandlerOptions) { + public static create( + instanceOrOptions?: HttpHandler | NodeHttp2HandlerOptions | Provider + ) { if (typeof (instanceOrOptions as any)?.handle === "function") { // is already an instance of HttpHandler. return instanceOrOptions as HttpHandler;