-
Notifications
You must be signed in to change notification settings - Fork 760
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
loose-vars
option to wrangler types
- Loading branch information
1 parent
376a46b
commit b4ac0d9
Showing
3 changed files
with
153 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
"wrangler": minor | ||
--- | ||
|
||
add `loose-vars` option to `wrangler types` | ||
|
||
add a new `--loose-vars` option to `wrangler types` that developers can use to get more | ||
loose types for their variables instead of literal and union types | ||
|
||
these more loose types can be useful when developers change often their `vars` values, | ||
even more so when multiple environments are involved | ||
|
||
## Example | ||
|
||
With a toml containing: | ||
|
||
```toml | ||
[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 --loose-vars` would instead generate: | ||
|
||
``` | ||
interface Env { | ||
MY_VARIABLE: string; | ||
MY_NUMBERS: number[]; | ||
} | ||
``` | ||
|
||
(allowing the developer to easily change their toml variables without the | ||
risk of braking typescript types) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters