From 3bf300a1c99ae4cf8038930c45e19ebd68db222e Mon Sep 17 00:00:00 2001 From: Zihua Li Date: Sat, 26 Mar 2022 18:48:47 +0800 Subject: [PATCH] fix: improve typing compatibility with @types/ioredis (#1542) --- lib/cluster/index.ts | 13 +++++++++---- lib/index.ts | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/cluster/index.ts b/lib/cluster/index.ts index 511407f9..c383d652 100644 --- a/lib/cluster/index.ts +++ b/lib/cluster/index.ts @@ -48,6 +48,14 @@ type OfflineQueueItem = { node: unknown; }; +export type ClusterNode = + | string + | number + | { + host?: string | undefined; + port?: number | undefined; + }; + type ClusterStatus = | "end" | "close" @@ -106,10 +114,7 @@ class Cluster extends Commander { /** * Creates an instance of Cluster. */ - constructor( - startupNodes: (string | number | object)[], - options: ClusterOptions = {} - ) { + constructor(startupNodes: ClusterNode[], options: ClusterOptions = {}) { super(); EventEmitter.call(this); diff --git a/lib/index.ts b/lib/index.ts index e3d65993..233232b6 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -52,6 +52,9 @@ export { } from "./connectors/SentinelConnector"; export { StandaloneConnectionOptions } from "./connectors/StandaloneConnector"; export { RedisOptions, CommonRedisOptions } from "./redis/RedisOptions"; +export { ClusterNode } from "./cluster"; +export { ClusterOptions } from "./cluster/ClusterOptions"; +export { NodeRole } from "./cluster/util"; // No TS typings export const ReplyError = require("redis-errors").ReplyError;