You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Posted to discord a few days ago and sounds like I'm not the only one with this problem.
In the worker where I'm calling the RPC, I'm defining the env:
export interface Env {
// other vars
MERCHANT_INSTANCE: DurableObjectNamespace<MerchantInstance>
}
typescript throws this error:
TS2344: Type MerchantInstance does not satisfy the constraint DurableObjectBranded
Property [__DURABLE_OBJECT_BRAND] is missing in type MerchantInstance but required in type DurableObjectBranded
I'm importing the types in the worker and using most recent versions of all packages in both the DO and separate worker where I'm calling the DO:
import { DurableObject } from "cloudflare:workers";
export interface Env {
}
export class MerchantInstance extends DurableObject {
constructor(state: DurableObjectState, env: Env) {
super(state, env)
}
async increment(amount = 1) {
let value: number = (await this.ctx.storage.get("value")) || 0;
value += amount;
await this.ctx.storage.put("value", value);
return value;
}
}
in addition to the typescript error in the Env type definition, I'm also not getting type completion on the 'increment method'. When calling the .increment() method on a stub, I get the TS error:
TS2339: Property increment does not exist on type DurableObjectStub<MerchantInstance>
The text was updated successfully, but these errors were encountered:
I ran into an issue with typescript in Durable Objects x RPC following these docs - https://developers.cloudflare.com/durable-objects/best-practices/create-durable-object-stubs-and-send-requests/#call-rpc-methods
Posted to discord a few days ago and sounds like I'm not the only one with this problem.
In the worker where I'm calling the RPC, I'm defining the env:
typescript throws this error:
I'm importing the types in the worker and using most recent versions of all packages in both the DO and separate worker where I'm calling the DO:
DO class is defined as:
in addition to the typescript error in the Env type definition, I'm also not getting type completion on the 'increment method'. When calling the .increment() method on a stub, I get the TS error:
TS2339: Property increment does not exist on type DurableObjectStub<MerchantInstance>
The text was updated successfully, but these errors were encountered: