In our application, we're adding quite a few config objects to app.locals that get used in our middleware.
const app = Express();
app.locals = {
someConfig: config
}
We currently have custom typings for the Request object that work without fail
declare namespace Express {
export interface Request {
featureFlags?: FeatureFlag;
}
}
I know locals comes from Express.Application so I tried this, and it doesn't work.
declare namespace Express {
export interface Application {
locals: {
someConfig: config;
};
}
export interface Request {
featureFlags?: FeatureFlag;
}
}
Has anyone successfully added types to app.locals?