Skip to content

Commit

Permalink
fix: Expose types for Cluster options
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Apr 6, 2022
1 parent 625f403 commit a37c555
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/cluster/ClusterOptions.ts
Expand Up @@ -6,15 +6,15 @@ import { NodeRole } from "./util";
export type DNSResolveSrvFunction = (
hostname: string,
callback: (
err: NodeJS.ErrnoException | undefined,
err: NodeJS.ErrnoException | null | undefined,
records?: SrvRecord[]
) => void
) => void;

export type DNSLookupFunction = (
hostname: string,
callback: (
err: NodeJS.ErrnoException | undefined,
err: NodeJS.ErrnoException | null | undefined,
address: string,
family?: number
) => void
Expand Down
7 changes: 6 additions & 1 deletion lib/index.ts
Expand Up @@ -54,7 +54,12 @@ export {
export { StandaloneConnectionOptions } from "./connectors/StandaloneConnector";
export { RedisOptions, CommonRedisOptions } from "./redis/RedisOptions";
export { ClusterNode } from "./cluster";
export { ClusterOptions } from "./cluster/ClusterOptions";
export {
ClusterOptions,
DNSLookupFunction,
DNSResolveSrvFunction,
NatMap,
} from "./cluster/ClusterOptions";
export { NodeRole } from "./cluster/util";
export type {
RedisKey,
Expand Down
14 changes: 12 additions & 2 deletions test/typing/options.test-d.ts
@@ -1,5 +1,5 @@
import { expectType } from "tsd";
import Redis, { Cluster } from "../../built";
import { expectAssignable, expectType } from "tsd";
import Redis, { Cluster, NatMap, DNSLookupFunction } from "../../built";

expectType<Redis>(new Redis());

Expand Down Expand Up @@ -39,3 +39,13 @@ expectType<Cluster>(
enableAutoPipelining: true,
})
);

expectAssignable<NatMap>({
"10.0.1.230:30001": { host: "203.0.113.73", port: 30001 },
"10.0.1.231:30001": { host: "203.0.113.73", port: 30002 },
"10.0.1.232:30001": { host: "203.0.113.73", port: 30003 },
});

expectAssignable<DNSLookupFunction>((address, callback) =>
callback(null, address)
);

0 comments on commit a37c555

Please sign in to comment.