Repository navigation
[config] Fix declaration emit for configs that use Durable Objects or wrap helpers - #16138
Merged
jamesopstad merged 2 commits intoOct 8, 2026
Merged
Conversation
… 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 detectedLatest commit: cb30633 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
2 of 5 tasks
workers-devprod
requested review from
a team and
dario-piotrowicz
and removed request for
a team
October 7, 2026 22:48
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
jamesopstad
requested review from
jamesopstad
and removed request for
dario-piotrowicz
October 8, 2026 08:02
jamesopstad
approved these changes
Oct 8, 2026
jamesopstad
left a comment
Contributor
There was a problem hiding this comment.
Nice fix! Thank you.
workers-devprod
approved these changes
Oct 8, 2026
workers-devprod
left a comment
Contributor
There was a problem hiding this comment.
Codeowners reviews satisfied
Merged
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.
Fixes #16137.
Projects that emit declarations couldn't export ordinary values built with
cf/config. Some public signatures use types that@cloudflare/config/public(whichcf/configre-exports) doesn't export. The most common case is an exported Worker with a Durable Object, which fails with TS4023. Other cases:define*helper fails with TS7056InferMainModulefails with TS4023 for a Worker without a knownentrypointJsonis silently emitted as/*elided*/ anyThe issue has a five-file repro against the published packages.
This exports those types from
@cloudflare/config/public, and makesdefineConfig,defineContaineranddefineWorkerfunction declarations:*BindingOptions, 6 trigger option types includingConnectTriggerOptionsBase, and 6DurableObject*ExportOptionsbindings.*,triggers.*andexports.*. tsc expandsConnectTrigger's variants into the base.WorkerEntrypointExportOptionsandWorkflowExportOptionswere already public.DurableObjectContainerConfig,StandardContainerConfigandContainerObservabilityConfigContainerConfig. They leak into every exported Worker with a Durable Object.DefaultModuleInferMainModuleresolves to without a knownentrypoint.Jsonbindings.json(). Otherwise it's inlined as/*elided*/ any.define*become function declarationstypeof 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 toanyThe
define*helpers keep their exact signatures, so inference doesn't change: emitting declarations for the same consumer config againstmainand this build gives byte-identical output. Editor parameter hints still show each helper's JSDoc and@example. I also tried a namedConfigDefinerinterface, but it dropped those docs.createConfigDefineris removed. It was internal, and onlydefinition.tsused it.Out of scope: building blocks that tsc never has to name (
BaseContainerConfig,ContainerImage, the inference helpers) stay private.Verification
[email protected],@cloudflare/[email protected]), on TypeScript 7.0.2 and 5.8.3:/*elided*/markers on 5.8.3 and 3 on 7.0.2.typeof defineWorker,DefaultModule,JsonandKvBindingOptions.main's build, they fail with 48 TS2305/TS2724 errors, one per type exported here.defineConfiggives byte-identical declarations (2,277 bytes) formainand this build.getSignatureHelpItemsfordefineConfig(,defineContainer(anddefineWorker(returns the same description and@exampletag as onmain.pnpm turbo check:type test:ci --filter=@cloudflare/config --force: 7 files and 276 tests passed.check:typeincludes the existing*.test-d.ts.oxlint --deny-warnings --type-aware packages/configandoxfmt --check: clean.mainand pass with this change (see Verification).Built and verified with Opus 5.5 in Claude Code.