From 3902ca6534fd64a798c5b2dc29402fe396d4a67c Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Sat, 24 Jun 2023 06:23:14 -0300 Subject: [PATCH] fix: `PoolCluster` typings --- typings/mysql/lib/PoolCluster.d.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/typings/mysql/lib/PoolCluster.d.ts b/typings/mysql/lib/PoolCluster.d.ts index db39b5a130..bf34111660 100644 --- a/typings/mysql/lib/PoolCluster.d.ts +++ b/typings/mysql/lib/PoolCluster.d.ts @@ -1,6 +1,13 @@ import { EventEmitter } from 'events'; import { PoolConnection } from './PoolConnection.js'; import { PoolOptions } from './Pool.js'; +import { ExecutableBase as ExecutableBaseClass } from './protocol/sequences/ExecutableBase.js'; +import { QueryableBase as QueryableBaseClass } from './protocol/sequences/QueryableBase.js'; + +// Expose class interfaces +declare class QueryableAndExecutableBase extends QueryableBaseClass( + ExecutableBaseClass(EventEmitter) +) {} export interface PoolClusterOptions { /** @@ -29,10 +36,20 @@ export interface PoolClusterOptions { defaultSelector?: string; } +export interface PoolNamespace extends QueryableAndExecutableBase { + getConnection( + callback: ( + err: NodeJS.ErrnoException | null, + connection: PoolConnection + ) => any + ): void; +} + declare class PoolCluster extends EventEmitter { config: PoolClusterOptions; add(config: PoolOptions): void; + add(group: string, connectionUri: string): void; add(group: string, config: PoolOptions): void; end(): void; @@ -59,7 +76,7 @@ declare class PoolCluster extends EventEmitter { ) => void ): void; - of(pattern: string, selector?: string): PoolCluster; + of(pattern: string, selector?: string): PoolNamespace; on(event: string, listener: (args: any[]) => void): this; on(event: 'remove', listener: (nodeId: number) => void): this;