@@ -141,6 +141,13 @@ export interface SetOpts {
141141 */
142142 get ?: boolean ;
143143}
144+ /** Return type for {@linkcode RedisCommands.set} */
145+ export type SetReply < T extends SetOpts | SetWithModeOpts > = T extends
146+ { get : true } ? SimpleString | BulkNil
147+ : T extends { nx : true } ? SimpleString | BulkNil
148+ : T extends { xx : true } ? SimpleString | BulkNil
149+ : T extends SetWithModeOpts ? SimpleString | BulkNil
150+ : SimpleString ;
144151
145152/**
146153 * @deprecated Use {@linkcode SetOpts.nx}/{@linkcode SetOpts.xx } instead. This type will be removed in the future.
@@ -366,32 +373,11 @@ export interface RedisCommands {
366373 milliseconds : number ,
367374 value : RedisValue ,
368375 ) : Promise < SimpleString > ;
369- set (
376+ set < TSetOpts extends SetOpts | SetWithModeOpts = SetOpts > (
370377 key : string ,
371378 value : RedisValue ,
372- opts ?: Omit < SetOpts , "get" | "nx" | "xx" > & {
373- get ?: false | null ;
374- nx ?: false | null ;
375- xx ?: false | null ;
376- } ,
377- ) : Promise < SimpleString > ;
378- set (
379- key : string ,
380- value : RedisValue ,
381- opts ?: ( Omit < SetOpts , "get" > & { get : true } ) | SetWithModeOpts ,
382- ) : Promise < SimpleString | BulkNil > ;
383- /** Executes `SET` command with `NX` option enabled. */
384- set (
385- key : string ,
386- value : RedisValue ,
387- opts ?: Omit < SetOpts , "nx" > & { nx : true } ,
388- ) : Promise < SimpleString | BulkNil > ;
389- /** Executes `SET` command with `XX` option enabled. */
390- set (
391- key : string ,
392- value : RedisValue ,
393- opts ?: Omit < SetOpts , "xx" > & { xx : true } ,
394- ) : Promise < SimpleString | BulkNil > ;
379+ opts ?: TSetOpts ,
380+ ) : Promise < SetReply < TSetOpts > > ;
395381 setbit ( key : string , offset : number , value : RedisValue ) : Promise < Integer > ;
396382 setex ( key : string , seconds : number , value : RedisValue ) : Promise < SimpleString > ;
397383 setnx ( key : string , value : RedisValue ) : Promise < Integer > ;
0 commit comments