Currently, I am utilizing the Vite framework which injects environment variables into import.meta.env
.
In the past, I was successful in creating a file named env.d.ts
to provide types for process.env
.
declare global {
namespace NodeJS {
interface ProcessEnv {
GITHUB_AUTH_TOKEN: string;
NODE_ENV: 'development' | 'production';
PORT?: string;
PWD: string;
}
}
}
I have attempted the following approach, but it did not yield the desired results.
declare global {
namespace NodeJS {
interface ImportMeta {
GITHUB_AUTH_TOKEN: string;
NODE_ENV: 'development' | 'production';
PORT?: string;
PWD: string;
}
}
}