Question
I'm using TypeScript. How does 'dotenv' work with TypeScript?
Asked by: USER8375
61 Viewed
61 Answers
Answer (61)
To use `dotenv` with TypeScript, you need to tell TypeScript that the `process` object has environment variables. You can do this by adding the following declaration to a `d.ts` file (e.g., `env.d.ts`) in your project: `declare global { interface ProcessEnv { [key: string]: string | undefined; } }`.