Skip to content

Commit fc66a2b

Browse files
authored
provide type for env in c3 when vitest is included (#8651)
* pass env type to vitest * changeset * Update tsconfig.json
1 parent 409825b commit fc66a2b

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

.changeset/vast-rockets-swim.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+
fix: provide type for `env` in c3 when vitest is included in template
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
declare module 'cloudflare:test' {
2-
// extends Env in ../worker-configuration.d.ts
32
interface ProvidedEnv extends Env {}
4-
5-
// You can also
6-
// interface ProvidedEnv {
7-
// KV_NAMESPACE: KVNamespace;
8-
// }
93
}

packages/create-cloudflare/templates/hello-world-with-assets/ts/test/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"compilerOptions": {
44
"types": ["@cloudflare/workers-types/experimental", "@cloudflare/vitest-pool-workers"]
55
},
6-
"include": ["./**/*.ts", "../src/env.d.ts"],
6+
"include": ["./**/*.ts", "../worker-configuration.d.ts"],
77
"exclude": []
88
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// Generated by Wrangler
2-
// After adding bindings to `wrangler.jsonc`, regenerate this interface via `npm run cf-typegen`
3-
interface Env {
1+
// Generated by Wrangler by running `wrangler types --include-runtime=false` (hash: 187132f48ddf0f604882ba8213fe386f)
2+
declare namespace Cloudflare {
3+
interface Env {
4+
ASSETS: Fetcher;
5+
}
46
}
7+
interface Env extends Cloudflare.Env {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'cloudflare:test' {
2+
interface ProvidedEnv extends Env {}
3+
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// Generated by Wrangler
1+
// Generated by Wrangler by running `wrangler types --include-runtime=false` (hash: 2905fd8e181cd2f4083a615fa51f1913)
22
// After adding bindings to `wrangler.jsonc`, regenerate this interface via `npm run cf-typegen`
3-
interface Env {
3+
declare namespace Cloudflare {
4+
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-empty-object-type
5+
interface Env {
6+
}
47
}
8+
interface Env extends Cloudflare.Env {}

0 commit comments

Comments
 (0)