@@ -235,7 +235,7 @@ export type RedisClientExtensions<
235235 M extends RedisModules = { } ,
236236 F extends RedisFunctions = { } ,
237237 S extends RedisScripts = { } ,
238- RESP extends RespVersions = 2 ,
238+ RESP extends RespVersions = 3 ,
239239 TYPE_MAPPING extends TypeMapping = { }
240240> = (
241241 WithCommands < RESP , TYPE_MAPPING > &
@@ -248,7 +248,7 @@ export type RedisClientType<
248248 M extends RedisModules = { } ,
249249 F extends RedisFunctions = { } ,
250250 S extends RedisScripts = { } ,
251- RESP extends RespVersions = 2 ,
251+ RESP extends RespVersions = 3 ,
252252 TYPE_MAPPING extends TypeMapping = { }
253253> = (
254254 RedisClient < M , F , S , RESP , TYPE_MAPPING > &
@@ -326,7 +326,7 @@ export default class RedisClient<
326326 M extends RedisModules = { } ,
327327 F extends RedisFunctions = { } ,
328328 S extends RedisScripts = { } ,
329- RESP extends RespVersions = 2
329+ RESP extends RespVersions = 3
330330 > ( config ?: CommanderConfig < M , F , S , RESP > ) {
331331
332332
@@ -359,7 +359,7 @@ export default class RedisClient<
359359 M extends RedisModules = { } ,
360360 F extends RedisFunctions = { } ,
361361 S extends RedisScripts = { } ,
362- RESP extends RespVersions = 2 ,
362+ RESP extends RespVersions = 3 ,
363363 TYPE_MAPPING extends TypeMapping = { }
364364 > ( this : void , options ?: RedisClientOptions < M , F , S , RESP , TYPE_MAPPING > ) {
365365 return RedisClient . factory ( options ) ( options ) ;
@@ -628,16 +628,17 @@ export default class RedisClient<
628628 }
629629
630630 #validateOptions( options ?: RedisClientOptions < M , F , S , RESP , TYPE_MAPPING > ) {
631- if ( options ?. clientSideCache && options ?. RESP !== 3 ) {
631+ const resp = options ?. RESP ?? 3 ;
632+ if ( options ?. clientSideCache && resp !== 3 ) {
632633 throw new Error ( 'Client Side Caching is only supported with RESP3' ) ;
633634 }
634- if ( options ?. emitInvalidate && options ?. RESP !== 3 ) {
635+ if ( options ?. emitInvalidate && resp !== 3 ) {
635636 throw new Error ( 'emitInvalidate is only supported with RESP3' ) ;
636637 }
637638 if ( options ?. clientSideCache && options ?. emitInvalidate ) {
638639 throw new Error ( 'emitInvalidate is not supported (or necessary) when clientSideCache is enabled' ) ;
639640 }
640- if ( options ?. maintNotifications && options ?. maintNotifications !== 'disabled' && options ?. RESP !== 3 ) {
641+ if ( options ?. maintNotifications && options ?. maintNotifications !== 'disabled' && resp !== 3 ) {
641642 throw new Error ( 'Graceful Maintenance is only supported with RESP3' ) ;
642643 }
643644 }
@@ -681,7 +682,7 @@ export default class RedisClient<
681682
682683 #initiateQueue( clientId : string ) : RedisCommandsQueue {
683684 return new RedisCommandsQueue (
684- this . #options. RESP ?? 2 ,
685+ this . #options. RESP ?? 3 ,
685686 this . #options. commandsQueueMaxLength ,
686687 ( channel , listeners ) => this . emit ( 'sharded-channel-moved' , channel , listeners ) ,
687688 clientId
@@ -693,7 +694,7 @@ export default class RedisClient<
693694 */
694695 private reAuthenticate = async ( credentials : BasicAuth ) => {
695696 // Re-authentication is not supported on RESP2 with PubSub active
696- if ( ! ( this . isPubSubActive && ! this . #options. RESP ) ) {
697+ if ( ! ( this . isPubSubActive && ( this . #options. RESP ?? 3 ) === 2 ) ) {
697698 await this . sendCommand (
698699 parseArgs ( COMMANDS . AUTH , {
699700 username : credentials . username ,
@@ -743,8 +744,9 @@ export default class RedisClient<
743744 > {
744745 const commands = [ ] ;
745746 const cp = this . #options. credentialsProvider ;
747+ const resp = this . #options. RESP ?? 3 ;
746748
747- if ( this . #options . RESP ) {
749+ if ( resp !== 2 ) {
748750 const hello : HelloOptions = { } ;
749751
750752 if ( cp && cp . type === 'async-credentials-provider' ) {
@@ -774,7 +776,7 @@ export default class RedisClient<
774776 hello . SETNAME = this . #options. name ;
775777 }
776778
777- commands . push ( { cmd : parseArgs ( HELLO , this . #options . RESP , hello ) } ) ;
779+ commands . push ( { cmd : parseArgs ( HELLO , resp , hello ) } ) ;
778780 } else {
779781 if ( cp && cp . type === 'async-credentials-provider' ) {
780782 const credentials = await cp . credentials ( ) ;
0 commit comments