Skip to content

Conversation

@edmundhung
Copy link
Member

@edmundhung edmundhung commented Jul 22, 2025

This PR updates Service<T> so that:

  • Returns Fetcher<T> when T is a WorkerEntrypoint class (Current behavior)
  • Returns Fetcher<InstanceType<T>> when T is a WorkerEntrypoint constructor
  • Returns never when T is a DurableObject or WorkflowEntrypoint
  • Returns Fetcher otherwise

This will enable wrangler types to infer the RPC methods from the default export with Service<typeof import("./worker").default> next.

Ref: cloudflare/workers-sdk#9897

@edmundhung edmundhung requested review from a team as code owners July 22, 2025 13:41
@github-actions
Copy link

github-actions bot commented Jul 22, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@edmundhung
Copy link
Member Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Jul 22, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jul 22, 2025

CodSpeed Performance Report

Merging #4588 will improve performances by 5.94%

Comparing edmundhung/improve-service-type (fb176e3) with main (40efdf6)

Summary

⚡ 1 improvements
✅ 8 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
request[RegExpBenchmark] 7.9 ms 7.5 ms +5.94%

@edmundhung edmundhung force-pushed the edmundhung/improve-service-type branch from 010f8c7 to 3c2da87 Compare July 22, 2025 17:08
@edmundhung edmundhung merged commit a86210a into main Jul 24, 2025
21 of 22 checks passed
@edmundhung edmundhung deleted the edmundhung/improve-service-type branch July 24, 2025 10:41
joshthoward pushed a commit that referenced this pull request Aug 7, 2025
…export (#4588)

* feat(types): allow Service<T> to handle non-WorkerEntrypoint default export

* restrict types accepted

* unwrap condition to avoid Fetcher<never>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants