Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(wrangler): prevent invalid JS identifiers in types generation (#5091
) * fix(wrangler): allow dashes in types generation * chore: add changeset * fix: wrap LOGFWDR_SCHEMA in quotes too for consistency * fix: check if identifier is valid for type generation * fix: retain var values * fix: actually retain var values * fix: escapeStringValue tests * chore: simplify logic * chore: update changeset * fix: allow $ at start of var * fix: address issues from review * chore: various improvements from review * Update packages/wrangler/src/__tests__/type-generation.test.ts Co-authored-by: Dario Piotrowicz <dario.piotrowicz@gmail.com> * chore: add additional type tests for constructType * fix: update snapshot for type generation tests --------- Co-authored-by: Dario Piotrowicz <dario.piotrowicz@gmail.com>
- Loading branch information
1 parent
f63e7a5
commit 6365c90
Showing
3 changed files
with
165 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,20 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
fix: better handle dashes and other invalid JS identifier characters in `wrangler types` generation for vars, bindings, etc. | ||
|
||
Previously, with the following in your `wrangler.toml`, an invalid types file would be generated: | ||
|
||
```toml | ||
[vars] | ||
some-var = "foobar" | ||
``` | ||
|
||
Now, the generated types file will be valid: | ||
|
||
```typescript | ||
interface Env { | ||
"some-var": "foobar"; | ||
} | ||
``` |
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