From af5a55d275d7ae83a4bad56cb61b1a8557e656bc Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Wed, 1 Jan 2025 17:22:47 +0100 Subject: [PATCH 1/8] add `--loose-vars` option to wrangler types command --- src/content/docs/workers/wrangler/commands.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 159f00f0fa60684..d9687d286e468b4 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -2287,6 +2287,10 @@ The minimum required Wrangler version to use this command is 3.66.0. - Leave the path blank to use the default option, e.g. `npx wrangler types --x-include-runtime` - A custom path must be relative to the project root, e.g. `./my-runtime-types.d.ts` - A custom path must have a `d.ts` extension. +- `--loose-vars` + - Flag used to generate "loose"/generic types instead of literal and union types for variables (e.g. `myEnv: string` instead of `myEnv: 'my env variable'`) + - Useful when environment variables can often change (especially with multiple environments involved) + From 60ddd7e46b9b548f198d9751c5176192f8ea85f5 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 14:29:20 +0100 Subject: [PATCH 2/8] fixup! add `--loose-vars` option to wrangler types command rename `--loose-vars` to `--strict-vars` --- src/content/docs/workers/wrangler/commands.mdx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index d9687d286e468b4..01af82306cc70d8 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -2287,10 +2287,9 @@ The minimum required Wrangler version to use this command is 3.66.0. - Leave the path blank to use the default option, e.g. `npx wrangler types --x-include-runtime` - A custom path must be relative to the project root, e.g. `./my-runtime-types.d.ts` - A custom path must have a `d.ts` extension. -- `--loose-vars` - - Flag used to generate "loose"/generic types instead of literal and union types for variables (e.g. `myEnv: string` instead of `myEnv: 'my env variable'`) - - Useful when environment variables can often change (especially with multiple environments involved) - +- `--strict-vars` + - Flag to opt out of the default generation of literal and union types for variables in favour of more generic types (e.g. to generate `myEnv: string` instead of `myEnv: 'my env variable'`) + - Useful when environment variables can often change (especially with multiple environments are involved) From 3ac05b16905b21e56f73d12b7087d6ccb394f332 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Tue, 21 Jan 2025 14:06:28 +0000 Subject: [PATCH 3/8] Update src/content/docs/workers/wrangler/commands.mdx Co-authored-by: Pete Bacon Darwin --- src/content/docs/workers/wrangler/commands.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 01af82306cc70d8..979bd37d1d5ef94 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -2288,7 +2288,9 @@ The minimum required Wrangler version to use this command is 3.66.0. - A custom path must be relative to the project root, e.g. `./my-runtime-types.d.ts` - A custom path must have a `d.ts` extension. - `--strict-vars` - - Flag to opt out of the default generation of literal and union types for variables in favour of more generic types (e.g. to generate `myEnv: string` instead of `myEnv: 'my env variable'`) + - Control the types that Wrangler generates for `vars` bindings. + - If true (the default) Wrangler generates literal and union types for bindings (e.g. `myEnv: 'my dev variable' | 'my prod variable'`). + - If false, Wrangler generates generic types (e.g. `myEnv: string`). - Useful when environment variables can often change (especially with multiple environments are involved) From 7722312493ceda0cd8eaedc595d54e4b86ce88d7 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Tue, 21 Jan 2025 14:07:27 +0000 Subject: [PATCH 4/8] add missing backticks --- src/content/docs/workers/wrangler/commands.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 979bd37d1d5ef94..ce089366e8000a0 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -2289,8 +2289,8 @@ The minimum required Wrangler version to use this command is 3.66.0. - A custom path must have a `d.ts` extension. - `--strict-vars` - Control the types that Wrangler generates for `vars` bindings. - - If true (the default) Wrangler generates literal and union types for bindings (e.g. `myEnv: 'my dev variable' | 'my prod variable'`). - - If false, Wrangler generates generic types (e.g. `myEnv: string`). + - If `true` (the default) Wrangler generates literal and union types for bindings (e.g. `myEnv: 'my dev variable' | 'my prod variable'`). + - If `false`, Wrangler generates generic types (e.g. `myEnv: string`). - Useful when environment variables can often change (especially with multiple environments are involved) From 56d330a92514a41f6c317e6b7d11322a0e17d003 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Tue, 21 Jan 2025 14:49:28 +0000 Subject: [PATCH 5/8] Update src/content/docs/workers/wrangler/commands.mdx Co-authored-by: ToriLindsay --- src/content/docs/workers/wrangler/commands.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index ce089366e8000a0..23179413704806f 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -2289,7 +2289,7 @@ The minimum required Wrangler version to use this command is 3.66.0. - A custom path must have a `d.ts` extension. - `--strict-vars` - Control the types that Wrangler generates for `vars` bindings. - - If `true` (the default) Wrangler generates literal and union types for bindings (e.g. `myEnv: 'my dev variable' | 'my prod variable'`). + - If `true`, (the default) Wrangler generates literal and union types for bindings (e.g. `myEnv: 'my dev variable' | 'my prod variable'`). - If `false`, Wrangler generates generic types (e.g. `myEnv: string`). - Useful when environment variables can often change (especially with multiple environments are involved) From 82f132501b0401b74f6e7b8aa7200a75651e34b0 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Tue, 21 Jan 2025 14:55:13 +0000 Subject: [PATCH 6/8] merge last two bullet points --- src/content/docs/workers/wrangler/commands.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 23179413704806f..50ea1c1d7d4d0d7 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -2290,8 +2290,7 @@ The minimum required Wrangler version to use this command is 3.66.0. - `--strict-vars` - Control the types that Wrangler generates for `vars` bindings. - If `true`, (the default) Wrangler generates literal and union types for bindings (e.g. `myEnv: 'my dev variable' | 'my prod variable'`). - - If `false`, Wrangler generates generic types (e.g. `myEnv: string`). - - Useful when environment variables can often change (especially with multiple environments are involved) + - If `false`, Wrangler generates generic types (e.g. `myEnv: string`) (useful when environment variables can often change especially when multiple environments are used). From bde6d136e86b7f32d1175252401fd15ce4ea30ba Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Tue, 21 Jan 2025 15:34:00 +0000 Subject: [PATCH 7/8] Update src/content/docs/workers/wrangler/commands.mdx Co-authored-by: ToriLindsay --- src/content/docs/workers/wrangler/commands.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 50ea1c1d7d4d0d7..bf29b1c6fcb1d01 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -2290,7 +2290,7 @@ The minimum required Wrangler version to use this command is 3.66.0. - `--strict-vars` - Control the types that Wrangler generates for `vars` bindings. - If `true`, (the default) Wrangler generates literal and union types for bindings (e.g. `myEnv: 'my dev variable' | 'my prod variable'`). - - If `false`, Wrangler generates generic types (e.g. `myEnv: string`) (useful when environment variables can often change especially when multiple environments are used). + - If `false`, Wrangler generates generic types (e.g. `myEnv: string`). This is useful when variables change frequently, such as when working across multiple environments. From ddd7c40eee8394fe36b2a45f2f7dea615c35b50c Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Tue, 21 Jan 2025 15:56:28 +0000 Subject: [PATCH 8/8] Update src/content/docs/workers/wrangler/commands.mdx --- src/content/docs/workers/wrangler/commands.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index bf29b1c6fcb1d01..f738c108e78e777 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -2290,7 +2290,7 @@ The minimum required Wrangler version to use this command is 3.66.0. - `--strict-vars` - Control the types that Wrangler generates for `vars` bindings. - If `true`, (the default) Wrangler generates literal and union types for bindings (e.g. `myEnv: 'my dev variable' | 'my prod variable'`). - - If `false`, Wrangler generates generic types (e.g. `myEnv: string`). This is useful when variables change frequently, such as when working across multiple environments. + - If `false`, Wrangler generates generic types (e.g. `myEnv: string`). This is useful when variables change frequently, especially when working across multiple environments.