ARTICLE AD BOX
Consumers won’t see it unless the augmentation ships with the package and TypeScript in the consuming project actually includes that .d.ts in its compilation.
Put the augmentation in your library and ensure it’s published
Example layout:
api/ src/ index.ts types/ express-augment.d.ts package.jsonExpose it as a subpath in package.json
{ "name": "@org/api", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }, "./express-augment": { "types": "./dist/express-augment.d.ts" } }, "files": ["dist"] }In each consuming project (JS or TS), add one import
Somewhere that runs once (app entrypoint):
import "@org/api/express-augment";Even in JS projects, you can add it in a .d.ts shim file.
That’s it. Now all projects “see” req.user.
