Repository navigation
Conversation
Callers of another app's API wrote the binding's type by hand, because
they do not have the provider's source for Cloudflare's `Service<T>`.
The compiler could not notice when the provider changed a method, and
generated APIs with hundreds of generic methods could not be copied.
`GET /api/v1/app-services/{service}/types` turns the active deployment's
documentation into declarations for one entrypoint and binding name, and
`widefleet services types APP --as BINDING` prints or writes them.
`--check` fails when the file no longer matches, for CI.
The binding is a plain interface with each documented signature,
including type parameters and TSDoc, so recursive types stay within the
compiler's instantiation limits. Results are typed as callers receive
them: a question's `requestState` arrives sealed, and `withInput` returns
the methods. Documented types keep their declarations, with field
descriptions on their members. Same-named types from different modules
are named after their modules. References the documentation does not
declare become `unknown`, keep their text in a comment and are listed in
the header.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | fc51109 | Nov 22 2026, 11:27 PM |
tnkuehne
added a commit
that referenced
this pull request
Nov 23, 2026
## Why
An app that calls another app's API writes the binding's type by hand,
for example `INVENTORY: { status(): Promise<{ configured: boolean }> }`.
Cloudflare's `Service<T>` needs the provider's source, which the caller
does not have. When the provider changes a method, the caller's compiler
does not notice; the error appears at runtime. Generated APIs cannot be
copied by hand at all: the Linear template has 424 methods with generic
selection types.
## What changes
- **API:** `GET
/api/v1/app-services/{service}/types?binding=LINEAR&entrypoint=default`
returns declarations generated from the active deployment's
documentation, with the same authorization as describe.
- **CLI:** `widefleet services types linear --as LINEAR [--entrypoint
NAME] [--output FILE] [--check]`. Without `--output` it prints the file;
`--check` fails with a usage error when the file differs from the active
deployment, so CI notices provider changes, including renamed types.
Line endings do not matter.
- **Generator (`serviceBindingTypes` in contracts):**
- The binding is a plain interface with every documented signature of
the entrypoint, including type parameters, overloads and TSDoc, not
`Service<T>`, so recursive types stay within the compiler's
instantiation limits.
- Results are typed as callers receive them: `LINEAR.Result<R>` replaces
a question's `requestState` with the sealed string, and
`withInput(answer)` returns the methods without `fetch`. `fetch` is
declared only for HTTP entrypoints.
- Documented types are declared as `interface` or `type` by their
`kind`, with their type parameters, sorted by name so document order
does not change the file. Field descriptions move onto their members
where the definition is one object type.
- Same-named types from different modules are named after their module,
such as `src_a_record_Entry`; a name already taken gains underscores.
- References the documentation does not declare, such as package
classes, become `unknown /* import("…").Token */` and are listed in the
header.
- A documented type named like the binding, or `Promise`, is refused
with a message.
- **Rewriter:** `shortenTypeNames` and the generator share one reference
scanner (`rewriteTypeReferences`); shortening is unchanged.
### Why the server generates the file
The documentation format is a storage contract of the platform (format
3) and the sealing of `requestState` is runtime behavior. Generating on
the server keeps both in one place, so CLI releases do not depend on the
stored format and the API offers the same types to every client. The CLI
only downloads, writes and compares. Raw documentation access through
the API is not added; no client needs it for this.
## Verification
- `pnpm typecheck`, `oxfmt --check .`, `oxlint --type-aware
--deny-warnings` on changed files, `cargo clippy`, `cargo test -p
platform-core -p platform-cli`
- `RUN_CLI_TESTS=1` `service-binding-types.test.ts`: a fixture app with
a generic declaration with constraint and default, recursive types,
same-named types from two modules, a package class, a question with
`requestState` and an HTTP entrypoint is documented by the native
extractor, generated, and a caller compiles against it with
`@tsconfig/strictest` and `skipLibCheck: false`, including
`@ts-expect-error` cases for constraints, missing arguments, unresolved
types and `withInput`.
- `app-services-cli.test.ts`: printing, `--output`, `--check` with a
matching, CRLF, changed and missing file.
- `app-services.integration.test.ts`: undocumented app, unknown
entrypoint, taken binding name, other organization.
- Contracts unit tests: naming of same-named types, unresolved
references with type arguments and `typeof`, field descriptions, refused
names.
- Linear template (828 types, 1.5 MB documentation, extracted locally):
generation takes about 0.2 s and yields 1.48 MB.
`templates/linear/tests/types.ts` compiles against the generated file
with `@tsconfig/strictest` and `skipLibCheck: false`, with only its
import line changed, including all `@ts-expect-error` cases.
- A small app that used four Linear methods through a hand-written
binding type compiles with the generated file in place of its own and
only its import line changed.
Documentation: #317 (draft).
<!-- greptile_comment -->
<!-- greptile_summary -->
<h2><a
href="https://app.greptile.com/api/retrigger?id=116038105&sig=cfdf1ead64379ed4d3377af664089775cd60570e08b663c3f3b0a4842d106779"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=mendra&next=%2Fwidefleet%2Fwidefleet%2Fpull%2F316&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>
<!-- greptile-impact-verdict --> The PR appears safe to merge; the
previous compilation issue is addressed.
<details open><summary><h3>Summary</h3></summary>
Adds generated TypeScript declarations for app service bindings through
the API and CLI.
- App service bindings now get TypeScript types from active API
documentation.
- The CLI can write or check generated app-service binding types.
</details>
<!-- greptile_confidence_score:5 -->
<sub>Reviews (2) · Last reviewed commit: ["Reject binding names that
cannot name
an..."](8b2ff52)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>
<!-- /greptile_comment -->
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents
widefleet services typesand its API route from #316 in the app services guide: generating a caller's binding types, using them in the caller,--checkin CI, andwithInputin generated types.Blocked on #316 and a release that includes it. Based on
feat/service-binding-types, so the diff contains only documentation.