0 votes
1 view
in Web Technology by (14.5k 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[];

    }

}

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...