Type Alias: RpcAccessible<T>
RpcAccessible<
T
> =Omit
<T
,"ctx"
|"env"
> &object
Defined in: packages/rpc/src/types.ts:120
Utility type that exposes Durable Object protected properties for RPC access.
When accessing Durable Object instances via RPC, TypeScript's protected modifier
is enforced at compile-time but does not restrict runtime access. This type utility
makes protected properties (like ctx
and env
) accessible in the type system
to match the runtime behavior.
This works by using Omit to remove the protected properties from the base type, then intersecting with explicit public declarations that match the actual Cloudflare Workers types.
Type Declaration
ctx
ctx:
DurableObjectState
env
env:
any
Type Parameters
T
T
Example
import type { RpcAccessible } from '@lumenize/rpc';
import { DurableObject } from 'cloudflare:workers';
class MyDO extends DurableObject {
async myMethod() { ... }
}
const client = createRpcClient<RpcAccessible<MyDO>>('MY_DO', 'instance-name');
const storage = await client.ctx.storage.get('key'); // No TypeScript error
await client.myMethod(); // Original methods still work