-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix NODE_ENV TypeScript duplication error in server env template #3189
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
Fix NODE_ENV TypeScript duplication error in server env template #3189
Conversation
…ring Co-authored-by: infomiho <2223680+infomiho@users.noreply.github.com>
process.env.NODE_ENV
is typed by deps
@copilot you didn't do the equivalent change in the client code |
Could you clarify what specific client-side change is needed? I looked at the client env template and it currently uses The server issue was from |
const { NODE_ENV = serverDevSchema.shape.NODE_ENV.value, ...restEnv } = process.env; | ||
export const env = ensureEnvSchema( | ||
{ NODE_ENV: serverDevSchema.shape.NODE_ENV.value, ...process.env }, | ||
{ NODE_ENV, ...restEnv }, | ||
serverEnvSchema, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we declare the default value at the schema level? It seems like it would be a nice place for that. I am not in love with this solution, it's a bit of an inscrutable workaround. (but if it's needed then so be it)
At any rate, I think we could do a couple things to improve:
const { NODE_ENV = serverDevSchema.shape.NODE_ENV.value, ...restEnv } = process.env; | |
export const env = ensureEnvSchema( | |
{ NODE_ENV: serverDevSchema.shape.NODE_ENV.value, ...process.env }, | |
{ NODE_ENV, ...restEnv }, | |
serverEnvSchema, | |
) | |
const defaultNodeEnv = serverDevSchema.shape.NODE_ENV.value; | |
// We manually extract `NODE_ENV` to avoid a TypeScript error about overwriting it blah blah | |
const { NODE_ENV: inputNodeEnv, ...restEnv } = process.env; | |
export const env = ensureEnvSchema( | |
{ | |
NODE_ENV: inputNodeEnv ?? defaultNodeEnv, | |
...restEnv | |
}, | |
serverEnvSchema, | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed on the call, we'll change as you proposed - but we'll refactor it later on when we upgrade to Zod 4
fc51f70
to
7b99b6a
Compare
7b99b6a
to
bf5ae4e
Compare
Fixes #3188
Note
Coded by Copilot, reviewed by human.