passport.js - how to declare typescript interface extension to node request session object? -


in following, returnto added session object passport methods. how declare interface in typescript?

import express = require('express'); import expresssession = require('express-session');  // how declare presence of returnto, 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); }; 

there's type declaration express-session on definitelytyped:

https://github.com/borisyankov/definitelytyped/blob/master/express-session/express-session.d.ts

following pattern in file, can create new d.ts (call whatever want) containing:

declare module express {   export interface session {     returnto: string;   } } 

typescript "merge" property existing definitions.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -