From 1951913b7c0b9a6cf1d65c45d4b31cee8246862c Mon Sep 17 00:00:00 2001 From: Timur Bolotov Date: Thu, 13 Apr 2023 22:35:35 +0600 Subject: [PATCH] [CCI] feat: add missing createConnection type (#490) * feat: add missing createConnection type Signed-off-by: Timur Bolotov --- CHANGELOG.md | 1 + lib/pool/index.d.ts | 7 +++++++ test/types/connection-pool.test-d.ts | 1 + 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcc9c6596..9134a0721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Removed unnecessary `data` argument when invoking `OpenSearchClientError` ([#421](https://github.com/opensearch-project/opensearch-js/pull/421)) - Fixed typos in `ConnectionPool` ([#427](https://github.com/opensearch-project/opensearch-js/pull/427)) - Added the solution for the possible error during yarn installation on Windows OS ([#435](https://github.com/opensearch-project/opensearch-js/issues/435)) +- Added missing `createConnection` method type definition in `BaseConnectionPool` )([#490](https://github.com/opensearch-project/opensearch-js/pull/490)) ### Dependencies diff --git a/lib/pool/index.d.ts b/lib/pool/index.d.ts index 97cbde41f..9a1296673 100644 --- a/lib/pool/index.d.ts +++ b/lib/pool/index.d.ts @@ -115,6 +115,13 @@ declare class BaseConnectionPool { * @returns {object|null} connection */ getConnection(opts?: getConnectionOptions): Connection | null; + + /** + * Creates a new connection instance. + * @param {object|string} opts + * @returns {Connection} + */ + createConnection(opts: ConnectionOptions | string): Connection; /** * Adds a new connection to the pool. * diff --git a/test/types/connection-pool.test-d.ts b/test/types/connection-pool.test-d.ts index e2df1334f..e4acf1988 100644 --- a/test/types/connection-pool.test-d.ts +++ b/test/types/connection-pool.test-d.ts @@ -60,6 +60,7 @@ import { ConnectionOptions } from '../../lib/Connection'; now: Date.now(), }) ); + expectType(pool.createConnection({ url: new URL('url') })); expectType(pool.addConnection({ url: new URL('url') })); expectType(pool.removeConnection(new Connection())); expectType(pool.empty());