I am making a basic API with express, typeORM and JWT
I followed this question to attach my users information to the Request in my middleware and it worked well.
But I decided that keeping only my usersId was not enough so I tried to save the entire User TypeOrm entity, but immediately I got the following error:
Property 'user' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.
So basically I have this extension
import { User } from "../entities/User";
declare namespace Express {
export interface Request {
user: User;
}
}
when I use it I get the following error
To me this makes absolutely no sense to me, because when I change it to this:
declare namespace Express {
export interface Request {
user: string;
}
}
it works perfectly fine
Could there be a hidden error that I am missing? could this be a bug at the frameworks level?
Thank you!