I am getting the following error when running ts-node.
I defined d.ts as follows to use "req.user" and applied tsconfig.json.
Path: src/@types/express/index.d.ts
import { User } from '../../model/user/user.interface';
declare global {
namespace Express {
interface Request {
user?: User['employeeId'];
}
}
}
tsconfig.json
{
"compilerOptions": {
"typeRoots": [
"./node_modules/@types",
"./src/@types"
],
"rootDir": ".",
"module": "CommonJS",
"strict": true,
"outDir": "dist",
"baseUrl": "./src",
"paths": {
"*": ["node_modules/@types/*", "src/@types"]
},
"esModuleInterop": true
},
"include": ["src/**/*.ts"]
}
controller
Path: src/api/posts/controller.ts
export const get = (req: Request, res: Response) => {
...
const { user } = req;
-> occrud Error
};
What am I missing?