Skip to content

fix(types): allow undefined or optional argument in DurableObjectNamespace.jurisdiction - #7547

Open
spideydotjs wants to merge 2 commits into
cloudflare:mainfrom
spideydotjs:fix/types-durable-object-jurisdiction-optional
Open

spideydotjs wants to merge 2 commits into
cloudflare:mainfrom
spideydotjs:fix/types-durable-object-jurisdiction-optional

Conversation

@spideydotjs

Copy link
Copy Markdown

Summary

Fixes #6551.

At runtime, DurableObjectNamespace.prototype.jurisdiction(maybeJurisdiction) accepts an optional argument (undefined or omitted), clearing or defaulting the jurisdiction constraint (implemented in #4763). This is commonly used in patterns such as:

const jurisdiction = env.WORKER_ENV ? 'eu' : undefined;
env.MY_DO.jurisdiction(jurisdiction);

However, the TypeScript definition declared jurisdiction as a required parameter (jurisdiction: DurableObjectJurisdiction), which caused TypeScript to reject undefined or zero-argument invocations.

This change marks the parameter as optional (jurisdiction?: DurableObjectJurisdiction) in src/workerd/api/actor.h, updates the generated type snapshots, and adds type-level tests in types/test/types/do.ts.

…space.jurisdiction

Fixes cloudflare#6551.

At runtime, DurableObjectNamespace.prototype.jurisdiction accepts an
optional argument (undefined or omitted), which defaults or clears the
jurisdiction constraint. This is commonly used in patterns such as:
const jurisdiction = env.WORKER_ENV ? 'eu' : undefined;
env.MY_DO.jurisdiction(jurisdiction);

However, the TypeScript definition declared jurisdiction as required,
rejecting undefined or empty calls at typecheck time.

Mark the jurisdiction parameter as optional in the JSG_TS_OVERRIDE blocks
in actor.h, update the generated type snapshots, and add type tests.
@spideydotjs
spideydotjs requested review from a team as code owners September 26, 2026 17:28
@cjol
cjol requested review from cjol and removed request for tpmmorris September 28, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing types for undefined jurisdiction

2 participants