workerd icon indicating copy to clipboard operation
workerd copied to clipboard

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

Open ctusch opened this issue 1 month ago • 0 comments

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
	}
}

ctusch avatar Dec 10 '25 22:12 ctusch