I have a DO that is defined in worker-a
I have a DO that is defined in worker-a but used in worker-b as well. I generate types for worker-b like this:
wrangler --cwd worker-b types -c wrangler.jsonc -c ../worker-a/wrangler.jsonc
This works and I get the right types when accessing the DO in worker-b.
The problem is that when I run tsc on worker-b I get type errors because the worker-configuration.d.ts imports all of worker-a (and not only the DO class):
interface Env {
do: DurableObjectNamespace<import("../worker-a/src/index").DO>;
}
worker-a uses env variables in code unrelated to the DO that are not available in worker-b which lead to the type error.
What is the recommended architecture for shared DOs? I was thinking of putting them in a separate worker that only holds the DOs and is not actually callable. But I'm not sure if that's how it's meant to be done.
wrangler --cwd worker-b types -c wrangler.jsonc -c ../worker-a/wrangler.jsonc
This works and I get the right types when accessing the DO in worker-b.
The problem is that when I run tsc on worker-b I get type errors because the worker-configuration.d.ts imports all of worker-a (and not only the DO class):
interface Env {
do: DurableObjectNamespace<import("../worker-a/src/index").DO>;
}
worker-a uses env variables in code unrelated to the DO that are not available in worker-b which lead to the type error.
What is the recommended architecture for shared DOs? I was thinking of putting them in a separate worker that only holds the DOs and is not actually callable. But I'm not sure if that's how it's meant to be done.