You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be assumed that environment variables are able to change, otherwise they would just be defined as constants instead. This kind of type generation seems to make more sense:
I don't think it's correct to assume that the values defined in wrangler.toml are the only possible values for the environment variables.
Secrets
Another issue is that secrets are only defined inside .dev.vars which isn't checked into version control. This creates issues for CI where the type generation isn't idemponent because .dev.vars doesn't exist in the CI environment. Changing the type generation to be more general will allow placeholder values to be defined in wrangler.toml for types.
Describe the solution
Problem
Wrangler generates the exact type for environment variables defined. For example, the following
wrangler.toml
:Generates this type:
It should be assumed that environment variables are able to change, otherwise they would just be defined as constants instead. This kind of type generation seems to make more sense:
I don't think it's correct to assume that the values defined in
wrangler.toml
are the only possible values for the environment variables.Secrets
Another issue is that secrets are only defined inside
.dev.vars
which isn't checked into version control. This creates issues for CI where the type generation isn't idemponent because.dev.vars
doesn't exist in the CI environment. Changing the type generation to be more general will allow placeholder values to be defined inwrangler.toml
for types.eg.
Different environments
This would also solve this relevant issue: #5850
Suggestion
Reference:
workers-sdk/packages/wrangler/src/type-generation.ts
Lines 157 to 173 in 5462ead
It makes more sense to me for the implementation of
constructTypes
to be something more like thisChanging the implementation or adding an extra flag to
wrangler types
to enable this behavior would be greatly appreciated.The text was updated successfully, but these errors were encountered: