In the following, returnTo
is added to the session object by my passport methods. How do I declare its interface in typescript?
import express = require('express');
import expressSession = require('express-session');
// how to declare presence of returnTo, which is not in underlying type?
export function createSession(req: express.Request, res: express.Response, next: Function) {
passport.authenticate('local', (err: any, user: UserInstance, info: any) => {
//. . .
req.logIn(user, (err) => {
//. . .
res.redirect(req.session.returnTo || '/');
});
})(req, res, next);
};
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…