Created
March 31, 2022 01:12
-
-
Save insyri/086e770b553b4ddcf43413905b78c50b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// There are two ways you can do this, the first being using a globals.d.ts file. | |
// Here, you would specify types like this.. | |
// .d.ts | |
namespace NodeJS { | |
interface ProcessEnv { | |
SUPER_SECRET_TOKEN: string; | |
} | |
} | |
// You may have to specify this in the tsconfig.json file. | |
// tsconfig.json | |
{ | |
"typeRoots": ["./path/to/global.d.ts", "./node_modules/@types"], | |
} | |
// Option two, in a .ts file. | |
// .ts | |
declare global { | |
namespace NodeJS { | |
export interface ProcessEnv { | |
SUPER_SECRET_TOKEN: string; | |
} | |
} | |
} | |
// https://dev.to/isthatcentered/typing-process-env-and-dealing-with-nodeenv-3ilm | |
// https://dev.to/asjadanis/parsing-env-with-typescript-3jjm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment