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; }'.
2
Answers
client.ZADD('test', { member: 'test', score: 10 })
should to the trickIn the redis types definitions files found in:
The interface definition for the type ZMember is the following:
So your function call should look like the following: