Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'useragent' does not exist on type 'Request<ParamsDictionary>' #128

Open
haveamission opened this issue Jan 24, 2020 · 4 comments

Comments

@haveamission
Copy link

Trying to use express-useragent with NodeJS/Express/TypeScript and getting this error.

Code:

app.get("/chat", keycloak.protect(), async (req, res) => {
    let chatController = new ChatController();
    let url = await chatController.openAppChat(req.useragent, channeluserId, merchantName);
    res.redirect(url);
});
@mostafiz93
Copy link

Facing the same issue.

@narendra-manchala
Copy link

Try installing types npm i -D @types/express-useragent

@LukeXF
Copy link

LukeXF commented Mar 8, 2021

Facing same issue
I tried creating a global types file as well and this doesn't solve it, neither does @Narendra67 answer.

import express from "express"
export default interface IRequest extends express.Request {
    useragent?: any;
}

@LukeXF
Copy link

LukeXF commented Mar 8, 2021

Creating a separate file and importing it higher up solved this issue:

declare global {
    namespace Express {
        interface Request {
            useragent?: any
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@mostafiz93 @LukeXF @haveamission @narendra-manchala and others