Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
Redis: Add to sorted set using TypeScript

I am trying to add a value to a sorted set in Redis using TypeScript like this client.ZADD('test', 10, 'test') but this throws an error

Argument of type '["test", 10, "test"]' is not assignable to parameter of type '[key: string, members: ZMember | ZMember[], options?: ZAddOptions | undefined] | [options: CommandOptions<ClientCommandOptions>, key: string, members: ZMember | ZMember[], options?: ZAddOptions | undefined]'.
  Type '["test", 10, "test"]' is not assignable to type '[options: CommandOptions<ClientCommandOptions>, key: string, members: ZMember | ZMember[], options?: ZAddOptions | undefined]'.
    Type at position 0 in source is not compatible with type at position 0 in target.
      Type 'string' is not assignable to type 'CommandOptions<ClientCommandOptions>'.
        Type 'string' is not assignable to type '{ readonly [symbol]: true; }'.
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

In the redis types definitions files found in:

node_modules\@node-redis\client\dist\lib\commands\generic-transformers.d.ts

The interface definition for the type ZMember is the following:

interface ZMember {
    score: number;
    value: string;
}

So your function call should look like the following:

client.zAdd('test_list', { score: 10, value: 'test'})
about 4 years ago · Juan Pablo Isaza Relatório

0

client.ZADD('test', { member: 'test', score: 10 }) should to the trick

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda