Open helloimalastair opened 2 months ago
cc @andyjessop
I belive wrangler types does use the type of the class now, so rpc should just work
eg: https://twitter.com/naporin24690/status/1824107980872376642
We shouldn't be putting undefined
though, do you have a repro where that happens?
Ooh, that's why... I was looking in a Pages Project that bound to a DO defined in a separate Worker... The Worker itself does have the correct types.
Would it be possible to generate types across multiple Workers/Pages projects, assuming that you have a reference to the source of them all available locally?
Yeah if we had a reference to the source it'll be straightforward to generate the type
We should definitely not generate <undefined>
there, that seems like a bug anyway
Oh, that's cool, I see in a comment that it does recognize the originating Worker. So it would just need a way to define multiple Workers that it could locate...
Also, my mistake on the <undefined>
part. It was based on the default param DurableObjectNamespace
, which is undefined
, but the actual Env
type has no param at all...
Sorry about that!
Describe the solution
Would it be possible to get the
wrangler types
command to generate proper types for RPC-enabled bindings, when binding to a Worker/DO that is defined in a different script? For example, Durable Object bindings pointing to a different script are always typed aswhich means that you cannot call any RPC methods on
DO_BINDING
stubs. Instead, it could be output asThis would require a bit of work for determining the location of multiple Workers at once, and would not work when you do not have the source for all of your Workers.