process.env is of type ProcessEnv with this definition:
export interface ProcessEnv {
    [key: string]: string | undefined;
}
I'd like to augment this TypeScript interface so that it contains the keys specific to my app, so that the result is something like:
export interface ProcessEnv {
    MY_VARIABLE_1: string;
    MY_OTHER_VARIABLE: string;
    [key: string]: string | undefined;
}
I cannot find a way to do it, I guess it will be declare module or declare namespace somewhere but cannot find a specific way to achieve this.
The ProcessEnv must be inside the namespace NodeJS and doesn't need to declare the [key: string]: string | undefined;, it inherits from the initial ProccessEnv.
declare namespace NodeJS {
  export interface ProcessEnv {
    MY_VARIABLE_1: string;
    MY_OTHER_VARIABLE: string;
  }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With