Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (19.9k points)

When trying to extend the Request interface from the package express to add some custom properties, I'm getting the following typescript error:

TS2339: Property '' does not exist on type 'Request<ParamsDictionary>'.

Do you know how to solve that?

1 Answer

0 votes
by (25.1k points)

Since a recent update of its typings and dependencies, I found that the following should fix the errors in your application.

In your tsconfig.json

{

  "compilerOptions": {

    //...

    "typeRoots": [

      "./custom_typings",

      "./node_modules/@types"

    ],

  }

// ...

}

And in your custom typings

// custom_typings/express/index.d.ts

declare namespace Express {

    interface Request {

        customProperties: string[];

    }

}

Property '' does not exist on type 'Request'
Intellipaat-community
by
hey can you tell me where I should put
    // custom_typings/express/index.d.ts

    declare namespace Express {

        interface Request {

            customProperties: string[];

        }

    }
this things??
thanks in advance
If possible can a give a brief explaination regarding the same

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...