我正在尝试在Typescript项目中使用express-session和express-mysql-session。这是我的代码的相关部分:

import * as express from "express";
import * as expressSession from "express-session";
import * as expressMySqlSession from "express-mysql-session";

this.express = express();
const sessionStore = new expressMySqlSession(sessionStoreConfig, this.dbConnection);
const sessionHandler = expressSession({
                ...,
                store: sessionStore
            });
this.express.use(sessionHandler);

它不会编译,因为store选项的类型为expressSession.Store | expressSession.MemoryStore | undefined,而sessionStore的类型为MySQLStore
我究竟做错了什么?

问候

最佳答案

尝试这个:

import * as express        from "express";
import * as expressSession from "express-session";
import expressMySqlSession from "express-mysql-session";

const MySQLStore   = expressMySqlSession(expressSession);
const sessionStore = new MySQLStore(sessionStoreConfig, this.dbConnection);
...

07-28 02:46