Skip to content

Commit 02f0699

Browse files
wrangler types - Import correct types for bound services (#8794)
* wrangler types - Import correct types for bound services if extra wrangler configs are provided * Use --config, Service type, and support external DOs * address comments * Create khaki-plums-clap.md * fixes * toml -> jsonc * fix lint --------- Co-authored-by: Samuel Macleod <[email protected]> Co-authored-by: Somhairle MacLeòid <[email protected]>
1 parent 6b42c28 commit 02f0699

File tree

5 files changed

+406
-131
lines changed

5 files changed

+406
-131
lines changed

.changeset/khaki-plums-clap.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
This adds support for more accurate types for service bindings when running `wrangler types`. Previously, running `wrangler types` with a config including a service binding would generate an `Env` type like this:
6+
7+
```ts
8+
interface Env {
9+
SERVICE_BINDING: Fetcher;
10+
}
11+
```
12+
13+
This type was "correct", but didn't capture the possibility of using JSRPC to communicate with the service binding. Now, running `wrangler types -c wrangler.json -c ../service/wrangler.json` (the first config representing the current Worker, and any additional configs representing service bound Workers) will generate an `Env` type like this:
14+
15+
```ts
16+
interface Env {
17+
SERVICE_BINDING: Service<import("../service/src/index").Entrypoint>;
18+
}
19+
```

0 commit comments

Comments
 (0)