diff --git a/types/redis/index.d.ts b/types/redis/index.d.ts index b838fcc1e9..003361f467 100644 --- a/types/redis/index.d.ts +++ b/types/redis/index.d.ts @@ -8,6 +8,7 @@ // James Garbutt // Bartek SzczepaƄski // Pirasis Leelatanon +// Stanislav Dzhus // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: https://github.com/types/npm-redis @@ -159,8 +160,8 @@ export interface Commands { /** * Set multiple hash fields to multiple values. */ - hmset: OverloadedSetCommand; - HMSET: OverloadedSetCommand; + hmset: OverloadedSetCommand; + HMSET: OverloadedSetCommand; /** * Listen for messages published to the given channels. @@ -393,8 +394,8 @@ export interface Commands { /** * Remove all keys from the current database. */ - flushdb(cb?: Callback): R; - FLUSHDB(cb?: Callback): R; + flushdb(cb?: Callback<'OK'>): R; + FLUSHDB(cb?: Callback<'OK'>): R; /** * Add one or more geospatial items in the geospatial index represented using a sorted set. @@ -1169,9 +1170,7 @@ export interface Commands { ZSCAN: OverloadedKeyCommand; } -export const RedisClient: { - new (options: ClientOpts): RedisClient; -}; +export const RedisClient: new (options: ClientOpts) => RedisClient; export interface RedisClient extends Commands, EventEmitter { connected: boolean; @@ -1221,9 +1220,7 @@ export interface RedisClient extends Commands, EventEmitter { BATCH(args?: Array>>): Multi; } -export const Multi: { - new (): Multi; -}; +export const Multi: new () => Multi; export interface Multi extends Commands { exec(cb?: Callback): boolean; diff --git a/types/redis/redis-tests.ts b/types/redis/redis-tests.ts index 5d7d617b91..fb5a97987d 100644 --- a/types/redis/redis-tests.ts +++ b/types/redis/redis-tests.ts @@ -9,6 +9,7 @@ const args: any[] = []; const resCallback: (err: Error | null, res: any) => void = () => {}; const numCallback: (err: Error | null, res: number) => void = () => {}; const strCallback: (err: Error | null, res: string) => void = () => {}; +const okCallback: (err: Error | null, res: 'OK') => void = () => {}; const messageHandler: (channel: string, message: any) => void = () => {}; // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- @@ -66,7 +67,7 @@ client.unref(); client.append(str, str, numCallback); client.bitcount(str, numCallback); client.bitcount(str, num, num, numCallback); -client.set(str, str, strCallback); +client.set(str, str, okCallback); client.get(str, strCallback); client.exists(str, numCallback); @@ -80,15 +81,15 @@ client.once(str, messageHandler); client.get('test'); client.get('test', resCallback); client.set('test', 'test'); -client.set('test', 'test', resCallback); +client.set('test', 'test', okCallback); client.mset(args, resCallback); client.incr(str, resCallback); // Friendlier hash commands client.hgetall(str, resCallback); -client.hmset(str, value, resCallback); -client.hmset(str, str, str, str, str, resCallback); +client.hmset(str, value, okCallback); +client.hmset(str, str, str, str, str, okCallback); // Publish / Subscribe client.publish(str, value); @@ -133,3 +134,5 @@ client.hincrbyfloat('a', 'b', 1.5, (error, value) => value.startsWith('1')); client.HINCRBYFLOAT('a', 'b', 1.5, (error, value) => value.startsWith('1')); client.zincrby('a', 1, 'b', strCallback); client.ZINCRBY('a', 1, 'b', strCallback); + +client.flushdb(okCallback);