Minor Changes
-
#5086
8faf2c0
Thanks @dario-piotrowicz! - add--strict-vars
option towrangler types
add a new
--strict-vars
option towrangler types
that developers can (by setting the
flag tofalse
) use to disable the default strict/literal types generation for their variablesopting out of strict variables can be useful when developers change often their
vars
values,
even more so when multiple environments are involvedExample
With a toml containing:
[vars] MY_VARIABLE = "production_value" MY_NUMBERS = [1, 2, 3] [env.staging.vars] MY_VARIABLE = "staging_value" MY_NUMBERS = [7, 8, 9]
the
wrangler types
command would generate the following interface:interface Env { MY_VARIABLE: "production_value" | "staging_value"; MY_NUMBERS: [1,2,3] | [7,8,9]; }
while
wrangler types --strict-vars=false
would instead generate:interface Env { MY_VARIABLE: string; MY_NUMBERS: number[]; }
(allowing the developer to easily change their toml variables without the
risk of breaking typescript types)
Patch Changes
-
#7720
902e3af
Thanks @vicb! - chore(wrangler): use the unenv preset from@cloudflare/unenv-preset
-
#7760
19228e5
Thanks @vicb! - chore: update unenv dependency version -
#7735
e8aaa39
Thanks @penalosa! - Unwrap the error cause when available to send to Sentry -
#5086
8faf2c0
Thanks @dario-piotrowicz! - fix: widen multi-envvars
types inwrangler types
Currently, the type generated for
vars
is a string literal consisting of the value of the variable in the top level environment. If multiple environments
are specified this wrongly restricts the type, since the variable could contain any of the values from each of the environments.For example, given a
wrangler.toml
containing the following:[vars] MY_VAR = "dev value" [env.production.vars] MY_VAR = "prod value"
running
wrangler types
would generate:interface Env { MY_VAR: "dev value"; }
making typescript incorrectly assume that
MY_VAR
is always going to be"dev value"
after these changes, the generated interface would instead be:
interface Env { MY_VAR: "dev value" | "prod value"; }
-
#7733
dceb196
Thanks @emily-shen! - feat: pull resource names for provisioning from config if providedUses
database_name
andbucket_name
for provisioning if specified. For R2, this only happens if there is not a bucket with that name already. Also respects R2jurisdiction
if provided. -
Updated dependencies []:
- miniflare@3.20241230.2