cloudflare / cloudflare/workerd

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

Open
#5,675 0 comments 1 reaction 1 assignee Claimed by @workers-devprod View on GitHub
types
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

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.

```TS
export class ADurableObject extends DurableObject {
async aMethod(): Promise // 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
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.