Now im following the Fullstack React GraphQL TypeScript Tutorial
I get trouble in connectRedis with express-session;;;
import connectRedis from "connect-redis";
import session from "express-session";
...
const RedisStore = connectRedis(session);
[ERROR]
error TS2345: Argument of type 'typeof session' is not assignable to parameter of type '(options?: SessionOptions | undefined) => RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.
Types of parameters 'options' and 'options' are incompatible.
Type 'import("/Users/jsyovo/Documents/2-MyRepository/2-ReactJS/14-reddit-clone/server/node_modules/@types/connect-redis/node_modules/@types/express-session/index").SessionOptions | undefined' is not assignable to type 'import("/Users/jsyovo/Documents/2-MyRepository/2-ReactJS/14-reddit-clone/server/node_modules/@types/express-session/index").SessionOptions | undefined'.
Type 'import("/Users/jsyovo/Documents/2-MyRepository/2-ReactJS/14-reddit-clone/server/node_modules/@types/connect-redis/node_modules/@types/express-session/index").SessionOptions' is not assignable to type 'import("/Users/jsyovo/Documents/2-MyRepository/2-ReactJS/14-reddit-clone/server/node_modules/@types/express-session/index").SessionOptions'.
Types of property 'store' are incompatible.
Type 'Store | undefined' is not assignable to type 'Store | MemoryStore | undefined'.
Type 'Store' is not assignable to type 'Store | MemoryStore | undefined'.
Type 'import("/Users/jsyovo/Documents/2-MyRepository/2-ReactJS/14-reddit-clone/server/node_modules/@types/connect-redis/node_modules/@types/express-session/index").Store' is not assignable to type 'import("/Users/jsyovo/Documents/2-MyRepository/2-ReactJS/14-reddit-clone/server/node_modules/@types/express-session/index").Store'.
Types of property 'load' are incompatible.
Type '(sid: string, callback: (err: any, session?: SessionData | undefined) => any) => void' is not assignable to type '(sid: string, fn: (err: any, session?: SessionData | null | undefined) => any) => void'.
Types of parameters 'callback' and 'fn' are incompatible.
Types of parameters 'session' and 'session' are incompatible.
Type 'SessionData | undefined' is not assignable to type 'SessionData | null | undefined'.
Type 'import("/Users/jsyovo/Documents/2-MyRepository/2-ReactJS/14-reddit-clone/server/node_modules/@types/connect-redis/node_modules/@types/express-session/index").SessionData' is not assignable to type 'Express.SessionData'.
The types of 'cookie.path' are incompatible between these types.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
22 const RedisStore = connectRedis(session);
Try rolling back to
"@types/express-session": "1.17.1"
"@types/connect-redis": "^0.0.14"
I have similar problems, and rolling back helps, although I do not think it is a good practice. I believe something wrong about typing in the new versions of these package
Well, I tried using the newest packages again, and remove "dist" and "tsc -w" again. There is no such error. So not sure what exactly the mechanism is.