Typescript error: RedisClientType type is missing `on` property
golopot opened this issue · 2 comments
Description
The RedisClientType type appears to be missing the on method. This causes a type-checking error when using .on to handle events. Below is an example that triggers the error:
import { createClient } from "redis";
const redis = createClient().on("error", (err) => {});
// ~~ Property 'on' does not exist on type 'RedisClientType...Node.js Version
v22.9.0
Redis Server Version
not relevant
Node Redis Version
redis@4.7.0
Platform
not relevant
Logs
No response
having the same issue when using this redis package in my turborepo, i get 'Property 'on' does not exist on type 'RedisClientType'.
however, was able to create a fresh project with bun and run this library with no issues, the issue only happens with pnpm
I was surprised to see typing errors with on and once methods in both mongoose and redis. Downgrading to TS 5.4.5 was a one way to solve the issue, but are you perhaps using discord.js (or other packages depending on it)? They were using module augmentation to change EventEmitter typings, which caused issues after TS 5.5 release. See this. It's been fixed for a while now, and after upgrading the package, typings are working fine with the latest TS installed.