Skip to content

Durable object method with return type "unknown" returns type "never" when used through its stub #5675

@ctusch

Description

@ctusch

When a method on a durable object return a value of type unknown (or an object with a property of type unknown), calling that method on its stub gives a result of type never. Tested with latest wrangler 4.35.0 and 4.50.0.

export class ADurableObject extends DurableObject<Env> {
	async aMethod(): Promise<unknown> // or Promise<{ a: number, b: unknown}>
	{ ... }
}

export default { 
	async fetch(request: Request, env: Env) {
		const res = await env.ADurableObject.getByName('test').aMethod();
		// res is of type never
	}
}

Metadata

Metadata

Labels

typesRelated to @cloudflare/workers-types

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions