-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: widen multi-env
vars
types in wrangler types
- Loading branch information
1 parent
2e78812
commit 376a46b
Showing
3 changed files
with
156 additions
and
24 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,39 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
fix: widen multi-env `vars` types in `wrangler types` | ||
|
||
Currently types for variable generate string literal, those are appropriate when | ||
a single environment has been specified in the config file but if multiple environments | ||
are specified this however wrongly restricts the typing, the changes here fix such | ||
incorrect behavior. | ||
|
||
For example, given a `wrangler.toml` containing the following: | ||
|
||
``` | ||
[vars] | ||
MY_VAR = "dev value" | ||
[env.production] | ||
[env.production.vars] | ||
MY_VAR = "prod value" | ||
``` | ||
|
||
running `wrangler types` would generate: | ||
|
||
```ts | ||
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: | ||
|
||
```ts | ||
interface Env { | ||
MY_VAR: "dev value" | "prod value"; | ||
} | ||
``` |
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