node.js - extending express application interface -


i trying extend expressjs application interface using declaration merging explained in express type definitions

declare module express {      // these open interfaces may extended in application-specific manner via declaration merging.     // see example method-override.d.ts (https://github.com/borisyankov/definitelytyped/blob/master/method-override/method-override.d.ts)     export interface request { }     export interface response { }     export interface application { } } 

so, app.ts looks this:

/// <reference path="typings/express/express.d.ts" />  declare module express {     export interface application {         testa: string;     }     export interface request {         testr: string;     } }  import express = require('express');  var    app  = express();  app.testa = "why not?"; app.use(function (req, res, next) {     req.testr = "xxx"; }) 

i errors:

"property testa not exist on type express"

"property testr not exist on type request"

any clues?

since using modules, declaration merging won't happen here. in app.ts there isn't express module merge it's making separate module definition. need move code...

declare module express {     export interface application {         testa: string;     }     export interface request {         testr: string;     } } 

...into .d.ts file interfaces merged ones in express.d.ts.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -