-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Support TypeScript file, e.g. env.ts
#151
Comments
Hello and thank you for the feature request. Unfortunately, I have no plans to support Typescript files. The main reason is that in order to support typescript files, I would have to depend on the Perhaps someday things will be different in regards to typescript, but for now, including such a large library (when env-cmd is trying to be as dependency-free as possible) is just not something I desire for this project. However, as I have stated before in the past, if enough users request this feature, I am happy to reconsider adding it. |
This should work 👇 // env-vars.d.ts
import envCmdRc from './.env-cmdrc.json';
type ENV_CMD_RC = typeof envCmdRc;
type Merge<A, B> = {
[K in keyof A | keyof B]: K extends keyof A
? K extends keyof B
? string
: string | undefined
: K extends keyof B
? string | undefined
: never;
};
type MergeEnvs<T extends object[]> = T extends [infer A, ...infer Rest]
? A extends object
? Rest extends object[]
? Merge<A, MergeEnvs<Rest>>
: never
: never
: {};
type LOCAL_ENV_VARS = ENV_CMD_RC['local'];
type DEVELOPMENT_ENV_VARS = ENV_CMD_RC['development'];
type STAGING_ENV_VARS = ENV_CMD_RC['staging'];
type PRODUCTION_ENV_VARS = ENV_CMD_RC['production'];
type ENV_VARS = MergeEnvs<
[LOCAL_ENV_VARS, DEVELOPMENT_ENV_VARS, STAGING_ENV_VARS, PRODUCTION_ENV_VARS]
>;
declare global {
namespace NodeJS {
interface ProcessEnv extends ENV_VARS {}
}
} |
Hi, thanks for maintaining this awesome library.
Would you please make support of TypeScript env file? E.g.
A significant benefit would be type-check support across env files.
Thanks in advanced =]
The text was updated successfully, but these errors were encountered: