Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCI] feat: add missing createConnection type #490

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,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

Expand Down
7 changes: 7 additions & 0 deletions lib/pool/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
1 change: 1 addition & 0 deletions test/types/connection-pool.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { ConnectionOptions } from '../../lib/Connection';
now: Date.now(),
})
);
expectType<Connection>(pool.createConnection({ url: new URL('url') }));
expectType<Connection>(pool.addConnection({ url: new URL('url') }));
expectType<BaseConnectionPool>(pool.removeConnection(new Connection()));
expectType<void>(pool.empty());
Expand Down