Align the typeEnv value type with default process env value type (#67804)
### What Align the typeEnv value type with default process env value type `string | undefined` ### Why? When the `experimental.typedEnv` is enabled, we generate a `env.d.ts` file during the Dev Server. The type for the loaded env values will be `string` on Dev (type inference). Since we do not generate the `env.d.ts` file during the build time, there could be confusion from the difference of env types between the Dev and Build. The reason we don't want to strongly type as `string` or `readonly string` is because the multiple environment: Dev, Preview, Production, where the env could be different. If we type in one place based on the loaded .env file, the environment (like deployment preview or deployment production) might not have these values in env files or they only have the env vars in Node.js `process.env`. So the type file in build could be unpredictable, after discussion we decided to keep the original type for values, but the keys of envs are still be able to hint during development. ### How? Temporarily infer the type as `string | undefined`. The `typedEnv` will serve as the intellisense (type hint). Closes NDX-84
Showing
Please
register
or
sign in
to comment