ratelimit-js: Redis object got conflicted
I get this error when try to use this package
src/lib/upstash.ts:15:3 - error ts(2322): Type 'import("/Users/khanh/RustRoverProjects/sshare/node_modules/@upstash/redis/nodejs").Redis' is not assignable to type 'Redis'.
The types returned by 'multi()' are incompatible between these types.
15 redis: ratelimitRedis,
~~~~~
import { Ratelimit } from '@upstash/ratelimit'
import { Redis } from '@upstash/redis/cloudflare'
import {
UPSTASH_RATELIMIT_REDIS_TOKEN,
UPSTASH_RATELIMIT_REDIS_URL,
} from 'astro:env/server'
export const ratelimitRedis = new Redis({
token: UPSTASH_RATELIMIT_REDIS_TOKEN,
url: UPSTASH_RATELIMIT_REDIS_URL,
enableTelemetry: false,
})
export const verifyPasswordRatelimit = new Ratelimit({
redis: ratelimitRedis,
limiter: Ratelimit.slidingWindow(10, '10 s'),
prefix: 'verify-password',
analytics: true,
})
package.json
"@upstash/ratelimit": "2.0.3",
"@upstash/redis": "1.34.3",
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (6 by maintainers)
The same happened to me in a NextJS project.
Hey @hckhanh, I tried a few stuff and I couldn’t find anything wrong with how we use peer dependencies. I opened an issue in the astro repo.
Meanwhile, a simple
// @ts-ignoreshould be enoughYes you are right, thanks a lot for reproduction repo.
It’s weird that it only happens with astro-check. I will look into it today