How to share worker code (monorepo, npm, lib, ...) with the new wrangler types --experimental-includ

Hello! We are trying to share a DO from a library in a typescript monorepo, but I believe this issue is applicable to any code sharing process (an NPM package, a lib in a monorepo, etc). With the new command npx wrangler types --experimental-include-runtime it generates a .wrangler/types/runtime.d.ts file containing a bunch of types needed for our lib. Example: SqlStorage, DurableObjectNamespace. If I have a DO in our app, everything is good and works fine. But when I move the DO in a lib, then the question of where to get the types from arise: - The lib can be used by several workers with different compatibility date or flags - the lib doesn't have a wrangler.toml to generate the types from The code will complain that the type for SqlStorage is missing for instance. Before generating the types, we were using @cloudflare/workers-types, referenced in the library tsconfig.json, and we didn't have issues. So, what's the best practice to share TS worker code?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server