Skip to content

Missing types for undefined jurisdiction #6551

@tnkuehne

Description

@tnkuehne

I'm using .jurisdiction("eu") on Durable Object namespaces and wanted to use the pattern described in #4745 and implmented in #4763 , passing undefined in local dev where workerd doesn't support jurisdiction:

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

This works at runtime but fails TypeScript type checking because the generated types still require DurableObjectJurisdiction and don't accept undefined.

declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> {
	newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
	idFromName(name: string): DurableObjectId;
	idFromString(id: string): DurableObjectId;
	get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
	getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
	jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;
}
type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
interface DurableObjectNamespaceNewUniqueIdOptions {
	jurisdiction?: DurableObjectJurisdiction;
}

Had Claude Code look into it and it suspects the JSG_TS_OVERRIDE blocks in actor.h weren't updated to match the C++ signature change from this PR.

Metadata

Metadata

Labels

typesRelated to @cloudflare/workers-types

Type

No type
No fields configured for issues without a type.

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions