Skip to content

Conversation

@mvonschledorn
Copy link
Contributor

Description

Fixes #1395

The zremrangebyscore command had incorrect TypeScript type definitions that only accepted number for min and max parameters, but the Redis protocol and Upstash REST API accept string values like '-inf' and '+inf'.

This PR aligns zremrangebyscore with the existing zcount command, which already uses number | string for score range parameters.

Changes

  • Updated min parameter type from number to number | string
  • Updated max parameter type from number to number | string

Before

export class ZRemRangeByScoreCommand extends Command<number, number> {
  constructor(cmd: [key: string, min: number, max: number], opts?: CommandOptions<number, number>)
}

After

export class ZRemRangeByScoreCommand extends Command<number, number> {
  constructor(cmd: [key: string, min: number | string, max: number | string], opts?: CommandOptions<number, number>)
}

Justification

  1. Redis Protocol Support: Redis ZREMRANGEBYSCORE accepts special string values like '-inf', '+inf', and '(value' for exclusive ranges

  2. Consistency: The ZCountCommand already uses this pattern (see zcount.ts)

  3. Runtime vs Types: The Upstash REST API already accepts these string values at runtime, this PR just fixes the TypeScript types to match

Testing

This change is purely a type definition update and doesn't affect runtime behavior. Users can now use the following without type errors:

// Now works without type assertions!
await redis.zremrangebyscore('mykey', '-inf', Date.now() - 900000);
await redis.zremrangebyscore('mykey', 0, '+inf');
await redis.zremrangebyscore('mykey', '(10', '(20'); // Exclusive ranges

References

mvonschledorn and others added 2 commits November 20, 2025 11:51
The zremrangebyscore command had incorrect TypeScript type definitions
that only accepted number for min and max parameters, but the Redis
protocol and Upstash REST API accept string values like '-inf' and '+inf'.

This change aligns zremrangebyscore with the existing zcount command,
which already uses number | string for score range parameters.

Changes:
- Updated min parameter type from 'number' to 'number | string'
- Updated max parameter type from 'number' to 'number | string'

Fixes upstash#1395
@CahidArda CahidArda requested a review from Copilot November 26, 2025 14:44
Copilot finished reviewing on behalf of CahidArda November 26, 2025 14:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes TypeScript type definitions for the zremrangebyscore command to properly support string values like '-inf', '+inf', and exclusive ranges (e.g., '(10') for min/max score parameters.

  • Updated the ZRemRangeByScoreCommand constructor to accept number | (${number} | "-inf" | "+inf" for min and max parameters
  • Added test coverage for "+inf" string value
  • Refactored existing test structure to use beforeEach/afterEach for better test isolation

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/commands/zremrangebyscore.ts Updated type definitions to support string score ranges including infinity values and exclusive ranges with template literal types
pkg/commands/zremrangebyscore.test.ts Refactored test structure with beforeEach/afterEach hooks and added test for "+inf" parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CahidArda CahidArda merged commit b635b96 into upstash:main Nov 26, 2025
renovate bot added a commit to inabagumi/mini-apps that referenced this pull request Nov 26, 2025
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@upstash/redis](https://redirect.github.com/upstash/upstash-redis) |
[`1.35.6` ->
`1.35.7`](https://renovatebot.com/diffs/npm/@upstash%2fredis/1.35.6/1.35.7)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@upstash%2fredis/1.35.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@upstash%2fredis/1.35.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@upstash%2fredis/1.35.6/1.35.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@upstash%2fredis/1.35.6/1.35.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>upstash/upstash-redis (@&#8203;upstash/redis)</summary>

###
[`v1.35.7`](https://redirect.github.com/upstash/redis-js/releases/tag/v1.35.7)

[Compare
Source](https://redirect.github.com/upstash/upstash-redis/compare/v1.35.6...v1.35.7)

#### What's Changed

- DX-2204: document telemetry configuration option by
[@&#8203;CahidArda](https://redirect.github.com/CahidArda) in
[upstash/redis-js#1393](https://redirect.github.com/upstash/redis-js/pull/1393)
- DX-2265: add Requester type declaration by
[@&#8203;CahidArda](https://redirect.github.com/CahidArda) in
[upstash/redis-js#1397](https://redirect.github.com/upstash/redis-js/pull/1397)
- Fix: zremrangebyscore should accept string | number for min/max scores
by [@&#8203;mvonschledorn](https://redirect.github.com/mvonschledorn) in
[upstash/redis-js#1396](https://redirect.github.com/upstash/redis-js/pull/1396)

#### New Contributors

- [@&#8203;mvonschledorn](https://redirect.github.com/mvonschledorn)
made their first contribution in
[upstash/redis-js#1396](https://redirect.github.com/upstash/redis-js/pull/1396)

**Full Changelog**:
<upstash/redis-js@v1.35.6...v1.35.7>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/inabagumi/mini-apps).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS45IiwidXBkYXRlZEluVmVyIjoiNDIuMTkuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiYm90OiByZW5vdmF0ZSJdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot added a commit to inabagumi/shinju-date that referenced this pull request Nov 26, 2025
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@upstash/redis](https://redirect.github.com/upstash/upstash-redis) |
[`1.35.6` ->
`1.35.7`](https://renovatebot.com/diffs/npm/@upstash%2fredis/1.35.6/1.35.7)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@upstash%2fredis/1.35.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@upstash%2fredis/1.35.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@upstash%2fredis/1.35.6/1.35.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@upstash%2fredis/1.35.6/1.35.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>upstash/upstash-redis (@&#8203;upstash/redis)</summary>

###
[`v1.35.7`](https://redirect.github.com/upstash/redis-js/releases/tag/v1.35.7)

[Compare
Source](https://redirect.github.com/upstash/upstash-redis/compare/v1.35.6...v1.35.7)

#### What's Changed

- DX-2204: document telemetry configuration option by
[@&#8203;CahidArda](https://redirect.github.com/CahidArda) in
[upstash/redis-js#1393](https://redirect.github.com/upstash/redis-js/pull/1393)
- DX-2265: add Requester type declaration by
[@&#8203;CahidArda](https://redirect.github.com/CahidArda) in
[upstash/redis-js#1397](https://redirect.github.com/upstash/redis-js/pull/1397)
- Fix: zremrangebyscore should accept string | number for min/max scores
by [@&#8203;mvonschledorn](https://redirect.github.com/mvonschledorn) in
[upstash/redis-js#1396](https://redirect.github.com/upstash/redis-js/pull/1396)

#### New Contributors

- [@&#8203;mvonschledorn](https://redirect.github.com/mvonschledorn)
made their first contribution in
[upstash/redis-js#1396](https://redirect.github.com/upstash/redis-js/pull/1396)

**Full Changelog**:
<upstash/redis-js@v1.35.6...v1.35.7>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/inabagumi/shinju-date).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS45IiwidXBkYXRlZEluVmVyIjoiNDIuMTkuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiYm90OiByZW5vdmF0ZSJdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Fix: zremrangebyscore should accept string | number for min/max scores

2 participants