You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With this, I get this cryptic error on cloudflareRateLimiter within app.use:
No overload matches this call.
Overload 1 of 21, '(...handlers: MiddlewareHandler<{ Bindings: Env; }, never, {}>[]): Hono<{ Bindings: Env; }, BlankSchema, "/">', gave the following error.
Argument of type 'MiddlewareHandler<{ Bindings: Env; }, string, Input>' is not assignable to parameter of type 'MiddlewareHandler<{ Bindings: Env; }, never, {}>'.
Types of parameters 'c' and 'c' are incompatible.
Type 'Context<{ Bindings: Env; }, never, {}>' is not assignable to type 'Context<{ Bindings: Env; }, string, Input>'.
Property '#private' in type 'Context' refers to a different member that cannot be accessed from within type 'Context'.
Overload 2 of 21, '(handler: MiddlewareHandler<{ Bindings: Env; }, never, {}>): Hono<{ Bindings: Env; }, BlankSchema, "/">', gave the following error.
Argument of type 'MiddlewareHandler<{ Bindings: Env; }, string, Input>' is not assignable to parameter of type 'MiddlewareHandler<{ Bindings: Env; }, never, {}>'.
Overload 3 of 21, '(path: string, ...handlers: MiddlewareHandler<{ Bindings: Env; }, string, {}>[]): Hono<{ Bindings: Env; }, BlankSchema, "/">', gave the following error.
Argument of type 'MiddlewareHandler<{ Bindings: Env; }, string, Input>' is not assignable to parameter of type 'string'.ts(2769)
I am not able to understand what this error is pointing at.
I tried the following approach to more closely match the documentation and exclude any mismatch in my configuration:
import{cloudflareRateLimiter,RateLimitBinding}from"@hono-rate-limiter/cloudflare";import{Hono}from"hono";typeAppType={Variables: {rateLimit: boolean;};Bindings: {RATE_LIMITER: RateLimitBinding;};};// Apply the rate limiting middleware to all requests.constapp=newHono<AppType>().use(cloudflareRateLimiter<AppType>({rateLimitBinding: (c)=>c.env.RATE_LIMITER,keyGenerator: (c)=>c.req.header("cf-connecting-ip")??"",// Method to generate custom identifiers for clients.}),);
On the first line, Module '"@hono-rate-limiter/cloudflare"' has no exported member 'RateLimitBinding'.ts(2305)
On cloudflareRateLimiter(...):
No overload matches this call.
Overload 1 of 21, '(...handlers: MiddlewareHandler<AppType, never, {}>[]): Hono<AppType, BlankSchema, "/">', gave the following error.
Argument of type 'MiddlewareHandler<AppType, string, Input>' is not assignable to parameter of type 'MiddlewareHandler<AppType, never, {}>'.
Types of parameters 'c' and 'c' are incompatible.
Type 'Context<AppType, never, {}>' is not assignable to type 'Context<AppType, string, Input>'.
Property '#private' in type 'Context' refers to a different member that cannot be accessed from within type 'Context'.
Overload 2 of 21, '(handler: MiddlewareHandler<AppType, never, {}>): Hono<AppType, BlankSchema, "/">', gave the following error.
Argument of type 'MiddlewareHandler<AppType, string, Input>' is not assignable to parameter of type 'MiddlewareHandler<AppType, never, {}>'.
Overload 3 of 21, '(path: string, ...handlers: MiddlewareHandler<AppType, string, {}>[]): Hono<AppType, BlankSchema, "/">', gave the following error.
Argument of type 'MiddlewareHandler<AppType, string, Input>' is not assignable to parameter of type 'string'.ts(2769)
Any suggestions as to what may be causing these errors?
The text was updated successfully, but these errors were encountered:
import{cloudflareRateLimiter,}from"@hono-rate-limiter/cloudflare";import{Hono}from"hono";typeAppType={Variables: {rateLimit: boolean;};Bindings: {RATE_LIMITER: RateLimit;};};// Apply the rate limiting middleware to all requests.constapp=newHono<AppType>().use(cloudflareRateLimiter<AppType>({rateLimitBinding: (c)=>c.env.RATE_LIMITER,keyGenerator: (c)=>c.req.header("cf-connecting-ip")??"",// Method to generate custom identifiers for clients.}));app.get("/",(c)=>{returnc.text("Hello Hono!");});exportdefaultapp;
RateLimit is the type coming from cloudflare/types, you can access it if you are using Cloudflare runtime with Hono
Hi, I've tried setting up the rate limiter with Hono but I'm running into strange TypeScript errors that I can't explain.
Here's the code I started with:
Where
../schemas.d.ts
is:With this, I get this cryptic error on
cloudflareRateLimiter
withinapp.use
:I am not able to understand what this error is pointing at.
I tried the following approach to more closely match the documentation and exclude any mismatch in my configuration:
Note how this code matches the sample at https://www.npmjs.com/package/@hono-rate-limiter/cloudflare.
I notice the following two Typescript errors:
Module '"@hono-rate-limiter/cloudflare"' has no exported member 'RateLimitBinding'.ts(2305)
cloudflareRateLimiter(...)
:Any suggestions as to what may be causing these errors?
The text was updated successfully, but these errors were encountered: