Workers SDK Issue Reports

← Back to Dashboard

#6905 `wrangler types` + DurableObjects + build process + typescript

Recommendation:KEEP OPEN
Difficulty:easy
Reasoning:

Valid bug: wrangler types generates imports from compiled JS (config.main) which has no types. Maintainers approved `--entry` flag solution Oct/Nov 2024, no implementation yet.

Suggested Action:

Keep open; invite PR from original reporter or add help wanted label

Analysis Report

Issue Review: cloudflare/workers-sdk#6905

Summary

wrangler types generates DurableObjectNamespace<import("./build/index").ClassName> which resolves to any because the compiled JS has no types; user needs ability to specify TypeScript source entrypoint.

Findings

  • Created: 2024-10-07
  • Updated: 2025-10-30
  • Version: 3.80.0 → 4.60.0 (current)
  • Component: wrangler (type-generation)
  • Labels: bug
  • Comments: 4

Key Evidence

  • Issue is a valid feature request/bug: when using a build process (e.g., Remix), wrangler.toml's main points to compiled JS (./build/index), not TS source
  • The generated types use import("./build/index").ClassName which has no type information
  • Maintainer @threepointone suggested adding --entry flag to wrangler types (Oct 2024)
  • Reporter offered to submit a PR
  • Maintainer @penalosa confirmed PRs welcome (Nov 2024)
  • No PR has been submitted or merged to address this
  • Current wrangler types (v4.60.0) does NOT have an --entry flag - verified via wrangler types --help
  • Code analysis confirms the issue: packages/wrangler/src/type-generation/index.ts uses config.main for DurableObject imports without considering that it may be compiled JS

Workaround

Reporter documents a valid workaround:

wrangler types --env-namespace EnvBeforeFixup

Then manually override in env.d.ts:

interface Env extends EnvBeforeFixup {
  DO: DurableObjectNamespace<import("./app/do").DrizzleTestDO>;
}

Recommendation

Status: KEEP OPEN

Reasoning: This is a valid bug/feature request that has been acknowledged by maintainers. The proposed solution (adding --entry flag to wrangler types) is clear and was endorsed by two maintainers. No fix has been implemented yet despite over a year passing. The issue affects users with build processes (Remix, Vite, etc.) who use DurableObjects.

Action: Keep open and consider prioritizing implementation. The reporter offered to submit a PR over a year ago - may be worth reaching out to see if they're still interested, or adding a "help wanted" or "good first issue" label to attract contributors.

Suggested Comment

Hi! This issue is still valid - the --entry flag has not been implemented yet. Just checking in: @zwily are you still interested in submitting a PR for this feature? If not, we can add a "help wanted" label to attract other contributors. The implementation would involve:

  1. Adding an --entry CLI option to wrangler types
  2. Using that path instead of config.main when generating import statements for DurableObject classes

The relevant code is in packages/wrangler/src/type-generation/index.ts.

Notes & Feedback (0)

No notes yet.

Add Note