From a834a66304f97b02fd9a3554640dd70936cb4d40 Mon Sep 17 00:00:00 2001 From: infernaldawn Date: Wed, 26 Apr 2017 19:29:41 +0200 Subject: [PATCH] Use union types instead of overloads (#16144) --- types/memcached/index.d.ts | 69 ++++++++++++++++--------------------- types/memcached/tslint.json | 5 +-- 2 files changed, 31 insertions(+), 43 deletions(-) diff --git a/types/memcached/index.d.ts b/types/memcached/index.d.ts index 24aa6beb3e..3c46efe396 100644 --- a/types/memcached/index.d.ts +++ b/types/memcached/index.d.ts @@ -13,25 +13,11 @@ declare class Memcached extends events.EventEmitter { static config: Memcached.options; /** - * Connect to a single server. - * @param location Server location e.g. "127.0.0.1:11211" + * Connect to a single Memcached server or cluster + * @param location Server locations * @param options options */ - constructor(location: string, options?: Memcached.options); - - /** - * Connect to a cluster of Memcached servers. - * @param location Server locations e.g. ["127.0.0.1:11211","127.0.0.1:11212"] - * @param options options - */ - constructor(location: string[], options?: Memcached.options); - - /** - * Connect to servers with weight. - * @param location Server locations e.g. {"127.0.0.1:11211": 1,"127.0.0.1:11212": 2} - * @param options options - */ - constructor(location: {[server: string]: number}, options ?: Memcached.options); + constructor(location: Memcached.Location, options?: Memcached.options); /** * Touches the given key. @@ -185,29 +171,9 @@ declare class Memcached extends events.EventEmitter { flush(cb: (this: undefined, err: any, results: boolean[]) => void): void; /** - * a issue occurred on one a server, we are going to attempt a retry next. + * Register event listener */ - on(event: "issue", cb: (err: Memcached.IssueData) => void): this; - - /** - * a server has been marked as failure or dead. - */ - on(event: "failure", cb: (err: Memcached.IssueData) => void): this; - - /** - * we are going to attempt to reconnect the to the failed server. - */ - on(event: "reconnecting", cb: (err: Memcached.IssueData) => void): this; - - /** - * successfully reconnected to the memcached server. - */ - on(event: "reconnect", cb: (err: Memcached.IssueData) => void): this; - - /** - * removing the server from our consistent hashing. - */ - on( event: "remove", cb: (err: Memcached.IssueData) => void): this; + on(event: Memcached.EventNames, cb: (err: Memcached.IssueData) => void): this; /** * Closes all active memcached connections. @@ -260,6 +226,31 @@ declare namespace Memcached { s: number; } + /** + * + */ + type EventNames = "issue" | "failure" | "reconnecting" | "reconnect" | "remove"; + + /** + * Declaration for single server or Memcached cluster location + * + * to connect to a single server use + * "127.0.0.1:11211" + * + * to connect to a cluster of Memcached servers use + * ["127.0.0.1:11211","127.0.0.1:11212"] + * + * to connect to servers with weight use + * {"127.0.0.1:11211": 1,"127.0.0.1:11212": 2} + */ + type Location = string | string[] | {[server: string]: number}; + interface options { /** * 250, the maximum key size allowed. diff --git a/types/memcached/tslint.json b/types/memcached/tslint.json index 08b1465cd6..f93cf8562a 100644 --- a/types/memcached/tslint.json +++ b/types/memcached/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "unified-signatures": false - } + "extends": "dtslint/dt.json" }