so what I want to do is to create a session and store it in redis.
I followed the API from this github repository https://github.com/tj/connect-redis.
But I am getting this error in the word client: The expected type comes from property ‘client’ which is declared here on type ‘RedisStoreOptions’.
This is the code that i used:
import redis from 'redis';
import session from 'express-session';
import connectRedis from 'connect-redis';
const app = express();
const RedisStore = connectRedis(session);
const redisClient = redis.createClient({ legacyMode: true });
redisClient.connect().catch(console.error);
app.use(
session({
store: new RedisStore({ client: redisClient }),
saveUninitialized: false,
secret: "keyboard cat",
resave: false,
})
)
The error occurs here:
store: new RedisStore({ client: redisClient })
More specifically in the word client.
2
Answers
I’m guessing your using TypeScript, I had this issue, did you install:
I did that and kept getting an error with the client so I uninstalled all 3 @types and noticed redis doesn’t require you to declare modules so I only installed types for express-session and connect-redis
instead of
use