Skip to content

Commit ca60010

Browse files
authored
Add type gen command to react + vite + assets template (#8349)
* rename to jsonc * add type gen * changeset * fix tsconfig
1 parent 187d887 commit ca60010

File tree

7 files changed

+13
-6
lines changed

7 files changed

+13
-6
lines changed

.changeset/shaggy-pugs-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
Add type generation command to React + Vite + Workers with Assets template and use `wrangler.jsonc` instead of `.json`.

packages/create-cloudflare/templates-experimental/react/c3.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ const config: TemplateConfig = {
169169
},
170170
generate,
171171
configure,
172-
transformPackageJson: async () => ({
172+
transformPackageJson: async (_, ctx) => ({
173173
scripts: {
174174
deploy: `${npm} run build && wrangler deploy`,
175175
preview: `${npm} run build && vite preview`,
176+
...(usesTypescript(ctx) && { "cf-typegen": `wrangler types` }),
176177
},
177178
}),
178179
devScript: "dev",

packages/create-cloudflare/templates-experimental/react/ts/api/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
interface Env {
2-
ASSETS: Fetcher;
3-
}
4-
51
export default {
62
fetch(request, env) {
73
const url = new URL(request.url);

packages/create-cloudflare/templates-experimental/react/ts/tsconfig.worker.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "./tsconfig.node.json",
33
"compilerOptions": {
44
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.worker.tsbuildinfo",
5-
"types": ["@cloudflare/workers-types/2023-07-01", "vite/client"],
5+
"types": ["@cloudflare/workers-types/2023-07-01", "./worker-configuration.d.ts", "vite/client"],
66
},
77
"include": ["api"],
88
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Generated by Wrangler
2+
// After adding bindings to `wrangler.jsonc`, regenerate this interface via `npm run cf-typegen`
3+
interface Env {
4+
ASSETS: Fetcher;
5+
}

0 commit comments

Comments
 (0)