typescript durable objects transaction api

Is there an example of how to type durable objects in the storage api?
state: DurableObjectState;
webSockets: Set<WebSocket>;
storage: DurableObjectStorage;
constructor(state: DurableObjectState, env: Env) {
this.state = state;
this.storage = state.storage;
this.webSockets = new Set();
}
state: DurableObjectState;
webSockets: Set<WebSocket>;
storage: DurableObjectStorage;
constructor(state: DurableObjectState, env: Env) {
this.state = state;
this.storage = state.storage;
this.webSockets = new Set();
}
I guess I'd want to define the type of stuff accessed through this.storage.get()/set()
1 Reply
kian
kian5mo ago
The methods are generic so you'd just do this.storage.get<T>(key, opts), etc