Skip to content

[config] Fix declaration emit for configs that use Durable Objects or wrap helpers - #16138

Merged
jamesopstad merged 2 commits into
cloudflare:mainfrom
Derpedyea:fix/config-nameable-public-types
Oct 8, 2026
Merged

jamesopstad merged 2 commits into
cloudflare:mainfrom
Derpedyea:fix/config-nameable-public-types

Conversation

@Derpedyea

@Derpedyea Derpedyea commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #16137.

Projects that emit declarations couldn't export ordinary values built with cf/config. Some public signatures use types that @cloudflare/config/public (which cf/config re-exports) doesn't export. The most common case is an exported Worker with a Durable Object, which fails with TS4023. Other cases:

  • wrapping a helper fails with TS4058
  • re-exporting a define* helper fails with TS7056
  • InferMainModule fails with TS4023 for a Worker without a known entrypoint
  • Json is silently emitted as /*elided*/ any

The issue has a five-file repro against the published packages.

This exports those types from @cloudflare/config/public, and makes defineConfig, defineContainer and defineWorker function declarations:

Change Why
Export every helper's options type: 31 *BindingOptions, 6 trigger option types including ConnectTriggerOptionsBase, and 6 DurableObject*ExportOptions Parameters of bindings.*, triggers.* and exports.*. tsc expands ConnectTrigger's variants into the base. WorkerEntrypointExportOptions and WorkflowExportOptions were already public.
Export DurableObjectContainerConfig, StandardContainerConfig and ContainerObservabilityConfig Members of the public ContainerConfig. They leak into every exported Worker with a Durable Object.
Export DefaultModule What InferMainModule resolves to without a known entrypoint.
Export Json Constraint of bindings.json(). Otherwise it's inlined as /*elided*/ any.
define* become function declarations Declarations can refer to them as typeof defineWorker. As factory-made constants, their type inlined a private conditional type (TS7056).

41 of the 48 new exports are interfaces that tsc has to name. The other 7 are type aliases, which tsc can inline, but they're exported anyway:

  • Json, because inlining a recursive alias degrades to any
  • 6 option aliases, so that every helper's options type can be imported by name

The define* helpers keep their exact signatures, so inference doesn't change: emitting declarations for the same consumer config against main and this build gives byte-identical output. Editor parameter hints still show each helper's JSDoc and @example. I also tried a named ConfigDefiner interface, but it dropped those docs. createConfigDefiner is removed. It was internal, and only definition.ts used it.

Out of scope: building blocks that tsc never has to name (BaseContainerConfig, ContainerImage, the inference helpers) stay private.

Verification

  • Published repro ([email protected], @cloudflare/[email protected]), on TypeScript 7.0.2 and 5.8.3:
    • Before: 6 errors on both versions (TS4023 ×3, TS2724, TS4058, TS7056), plus 91 /*elided*/ markers on 5.8.3 and 3 on 7.0.2.
    • After (this build packed and installed over 0.24.0): 0 errors and 0 elisions on both. The emitted declarations name typeof defineWorker, DefaultModule, Json and KvBindingOptions.
  • Consumer type tests from [config] Add consumer-style tests for the public type surface #15960, which is stacked on this PR:
    • Against main's build, they fail with 48 TS2305/TS2724 errors, one per type exported here.
    • With the export list removed, the emit checks alone fail with TS4023 ×40 and TS7056.
    • They pass with this change.
  • Behavior: a consumer config using KV, text and JSON bindings, scheduled and connect triggers, a Worker export, factory, promise and Durable Object container forms, and defineConfig gives byte-identical declarations (2,277 bytes) for main and this build.
  • Docs: getSignatureHelpItems for defineConfig(, defineContainer( and defineWorker( returns the same description and @example tag as on main.
  • Package checks:
    • pnpm turbo check:type test:ci --filter=@cloudflare/config --force: 7 files and 276 tests passed. check:type includes the existing *.test-d.ts.
    • oxlint --deny-warnings --type-aware packages/config and oxfmt --check: clean.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: the consumer type tests requested in review live in [config] Add consumer-style tests for the public type surface #15960, which is stacked on this PR. They fail on main and pass with this change (see Verification).
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this only adds type exports to an experimental package. Runtime behavior and config don't change.

Built and verified with Opus 5.5 in Claude Code.


Devin Review

… wrap helpers

Public signatures referenced types that `@cloudflare/config/public` didn't
export, so consumers that generate declarations hit TS4023 when exporting a
Worker with a Durable Object or wrapping a helper, TS7056 when re-exporting a
`define*` helper, and `/*elided*/ any` wherever `Json` was inlined. Export
every helper's options type, `Json`, `DefaultModule`, and the Container
config variants, and make the `define*` helpers function declarations so
declarations can refer to them by name.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@changeset-bot

changeset-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cb30633

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@cloudflare/config Patch
@cloudflare/autoconfig Patch
@cloudflare/build-output-utils Patch
@cloudflare/containers-shared Patch
@cloudflare/deploy-helpers Patch
@cloudflare/remote-bindings Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team October 7, 2026 22:48
@workers-devprod

workers-devprod commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment thread packages/config/src/public.ts Resolved
@pkg-pr-new

pkg-pr-new Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@16138

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@16138

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@16138

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@16138

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@16138

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@16138

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@16138

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@16138

miniflare

npm i https://pkg.pr.new/miniflare@16138

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@16138

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@16138

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@16138

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@16138

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@16138

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@16138

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@16138

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@16138

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@16138

wrangler

npm i https://pkg.pr.new/wrangler@16138

commit: cb30633

@jamesopstad
jamesopstad requested review from jamesopstad and removed request for dario-piotrowicz October 8, 2026 08:02

@jamesopstad jamesopstad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix! Thank you.

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@jamesopstad
jamesopstad merged commit b606624 into cloudflare:main Oct 8, 2026
70 of 71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Declaration emit fails for cf/config Workers with Durable Objects and for wrapped helpers (TS4023, TS7056)

3 participants