To add a custom request head for deserialize user in authentication
Property 'user' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.
To fix the error,two things needs to be done
- add type roots in
tsconfig.json
1
2
3
4
5
// tsconfig.json
"typeRoots": [
"./typings",
"./node_modules/@types"
] /* List of folders to include type definitions from. */,
- add the custom type here
1
2
3
4
5
6
7
8
// typings/express/index.d.ts
declare namespace Express {
interface Request {
customTypes: {
// add the custom types here
};
}
}
more infos refers to the link