Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions types/defines/ratelimit.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
interface RateLimitOptions {
key: string
/**
* Amount to add to the counter for this call. Must be a positive integer;
* defaults to `1`. The call is allowed while the counter is below the limit,
* even if `delta` takes it past the limit.
*/
delta?: number
}

interface RateLimitOutcome {
Expand Down
6 changes: 6 additions & 0 deletions types/generated-snapshot/experimental/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16552,6 +16552,12 @@ interface JsonWebKeyWithKid extends JsonWebKey {
}
interface RateLimitOptions {
key: string;
/**
* Amount to add to the counter for this call. Must be a positive integer;
* defaults to `1`. The call is allowed while the counter is below the limit,
* even if `delta` takes it past the limit.
*/
delta?: number;
}
interface RateLimitOutcome {
success: boolean;
Expand Down
6 changes: 6 additions & 0 deletions types/generated-snapshot/experimental/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16462,6 +16462,12 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
}
export interface RateLimitOptions {
key: string;
/**
* Amount to add to the counter for this call. Must be a positive integer;
* defaults to `1`. The call is allowed while the counter is below the limit,
* even if `delta` takes it past the limit.
*/
delta?: number;
}
export interface RateLimitOutcome {
success: boolean;
Expand Down
6 changes: 6 additions & 0 deletions types/generated-snapshot/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16186,6 +16186,12 @@ interface JsonWebKeyWithKid extends JsonWebKey {
}
interface RateLimitOptions {
key: string;
/**
* Amount to add to the counter for this call. Must be a positive integer;
* defaults to `1`. The call is allowed while the counter is below the limit,
* even if `delta` takes it past the limit.
*/
delta?: number;
}
interface RateLimitOutcome {
success: boolean;
Expand Down
6 changes: 6 additions & 0 deletions types/generated-snapshot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16099,6 +16099,12 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
}
export interface RateLimitOptions {
key: string;
/**
* Amount to add to the counter for this call. Must be a positive integer;
* defaults to `1`. The call is allowed while the counter is below the limit,
* even if `delta` takes it past the limit.
*/
delta?: number;
}
export interface RateLimitOutcome {
success: boolean;
Expand Down
17 changes: 17 additions & 0 deletions types/test/types/ratelimit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2026 Cloudflare, Inc.
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0

function expectType<T>(_value: T) {}

declare const limiter: RateLimit;

expectType<Promise<RateLimitOutcome>>(limiter.limit({ key: 'user-123' }));
expectType<Promise<RateLimitOutcome>>(
limiter.limit({ key: 'user-123', delta: 5 })
);

// @ts-expect-error `delta` must be a number.
limiter.limit({ key: 'user-123', delta: '5' });
// @ts-expect-error `key` is required.
limiter.limit({ delta: 5 });
Loading