interface?
                  
                  
                  I have this route:
                  
                  
                  
                  
                  
                  router.get('/', auth, async (req: AuthRequest, res: Response) => {
                  
                  
                  
                  
                  
                  which use this interface
                  
                  
                  
                  
                  
                  interface AuthRequest extends express.Request {
                  
                  
                    user: {
                  
                  
                      id: string;
                  
                  
                    }
                  
                  
                  }
                  
                  
                  
                  
                  
                  
                  
                  
                  for some reason I get:
                  
                  
                  
                  
                  
                  No overload matches this call.
                  
                  
                    Overload 1 of 3, '(path: PathParams, ...handlers: RequestHandler<ParamsDictionary, any, any, ParsedQs>[]): Router', gave the following error.
                  
                  
                      Argument of type '(req: AuthRequest, res: Response) => Promise<void>' is not assignable to parameter of type 'RequestHandler<ParamsDictionary, any, any, ParsedQs>'.
                  
                  
                        Types of parameters 'req' and 'req' are incompatible.
                  
                  
                          Property 'user' is missing in type 'Request<ParamsDictionary, any, any, ParsedQs>' but required in type 'AuthRequest'.
                  
                  
                    Overload 2 of 3, '(path: PathParams, ...handlers: RequestHandlerParams<ParamsDictionary, any, any, ParsedQs>[]): Router', gave the following error.
                  
                  
                      Argument of type '(req: AuthRequest, res: Response) => Promise<void>' is not assignable to parameter of type 'RequestHandlerParams<ParamsDictionary, any, any, ParsedQs>'.
                  
                  
                        Type '(req: AuthRequest, res: Response) => Promise<void>' is not assignable to type 'RequestHandler<ParamsDictionary, any, any, ParsedQs>'.
                  
                  
                  
                  
                  
                  what I did wrong? @TRGWII
                  
                  
                
I'm about to solve this issue in another project, I'll go do that and report back heh
https://stackoverflow.com/questions/37377731/extend-express-request-object-using-typescript
Обсуждают сегодня