I can see this. I learned from a friend to use Zod to check for process.env. I refined it a bit and got: ``` const EnvSchema = z.object({ NODE_ENV: z.enum(['development', 'production', 'staging']), DATABASE_URL: z.string(), POSTHOG_KEY: z.string(), }); export type AlertDownEnv = z.infer ; export function getEnvironments(env: Record ): AlertDownEnv { return EnvSchema.parse(env); } ``` Then you can: ``` const env = get…
I am quite surprised people here doesn't know how to validate data in runtime. The author completely mixing Typescript with runtime behavior.
a?.b?.c?.() or var ?? something have well documented use cases and it's not what the author is thinking.