// tsconfig.json inside "compilerOptions"
"typeRoots": ["./@types", "./node_modules/@types"],
// {projectRoot}/@types/express/index.d.ts
declare global {
namespace Express {
interface Request {
verifiedAccessToken: string
}
}
}
In another file with req annotated to Request inside the function parameter, I am still not able to set verifiedAccessToken without a lint error in VsCode:
req.verifiedAccessToken = accessToken;
// Property 'verifiedAccessToken' does not exist on
// type 'Request<ParamsDictionary, any, any, ParsedQs>'.ts(2339)
Anything else that needs to be done for the declaration file to be used?
// package.json, relevent deps
"dependencies": {
"express": "^4.17.1",
"node-typescript": "^0.1.3",
"ts-node": "^9.0.0",
"typescript": "^3.9.7"
},
"devDependencies": {
"@types/express": "^4.17.8",
"@types/node": "^14.0.27",