Say that I want to use dotenv module in my TypeScript project and install its .d.ts using npm install @types/dotenv --save. Then I realize that the
You can patch @types/foo locally for your app by patch-package.
Run npm i -D patch-package
Simply modify node_modules/@types/foo to suit your needs.
Run npx patch-package @types/foo. This creates a diff file in patches/ that records the changes made from the last step.
Add scripts: {postinstall: "patch-package"} in package.json. This make patches to be applied each time people run npm install.