typing express & nestjs, start project errors

Viewed 1354

I’m using nestJS. When I start the project, I have the following error. Is it a problem from the @types/express package ? Or is it something I did wrong ? Thanks.

[14:17:06] Starting compilation in watch mode...

node_modules/@types/express/index.d.ts:99:42 - error TS2344: Type 'P' does not satisfy the constraint 'Params'.
      Type 'P' is not assignable to type 'ParamsArray'.

     extends core.ErrorRequestHandler<P, ResBody, ReqBody, ReqQuery> { }
                                        ~

node_modules/@types/express/index.d.ts:108:124 - error TS2344: Type 'P' does not satisfy the constraint 'Params'.
      Type 'P' is not assignable to type 'ParamsArray'.

     interface Request<P = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = core.Query> extends core.Request<P, ResBody, ReqBody, ReqQuery> { }
                                                                                                                          
node_modules/@types/express/index.d.ts:109:138 - error TS2344: Type 'P' does not satisfy the constraint 'Params'.
      Type 'P' is not assignable to type 'ParamsArray'.

     interface RequestHandler<P = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = core.Query> extends core.RequestHandler<P, ResBody, ReqBody, ReqQuery> { }
                                                                                                                                        
[14:17:17] Found 3 errors. Watching for file changes.
2 Answers

I had the same problem with compilation, though just deleting package-lock.json didn't work for me. However, this did: npm update @types/express-serve-static-core --depth 1... It's suggested in the linked issue

as mentioned here, just remove the package-lock.json, and reinstall packages.

Related