I'm having issues doing a global extension of Express's Request option. Namely doing it the "proper" way the new property is not recognized by VS Code's TS engine whereas using the "improper" way, it is.
Contents of my ./@types/express/index.d.ts
// NOT working
declare global {
namespace Express {
interface Request {
testProp: { testProp: string };
}
}
}
// Working
declare namespace Express {
export interface Request {
testProp: { testProp: string };
}
}
Contents of my tsconfig.json
"typeRoots": [
"@types",
"./node_modules/@types",
"./src/lib"
]
What could be the issue causing the first method, which every resource tells me is the "right" way to do this, not to work? I do not get autocompletion for testProp, whereas with the second method, I do.
If it helps, using the first method hovering over "interface Request" gives its type as "globalThis.Express.Request" whereas in the second method it's just "Express.Request".