The `request` type inferred from `ExportedHandler` is `any` instead of `Request`.
Can you provide a reproduction (perhaps git repository) that we can use to diagnose this problem?
I am having the same issue right now. For me @cloudflare/[email protected] + [email protected] were definitely working, and I see this issue appearing with the at latest @cloudflare/[email protected] + [email protected], although possible earlier.
I did sort of a bisect of wrangler versions x @cloudflare/worker-types. The last version of wrangler that I found compatible with the last working version of worker-types was 3.36.0 x 4.20240208.0.
In other words, npm install [email protected] @cloudflare/[email protected] --save-dev is the latest version of the two working together, for me at least.
One caveat though is that I was testing this against my particular use case, which was with PagesFunction<Env>, not ExportedHandler.
I could be wrong but it looks like the issue was introduced about 6 months ago, here https://github.com/cloudflare/workerd/blame/a47804f8bbcd06904bb9eae91e0e6c3ffdc7f6d6/types/defines/pages.d.ts#L4.
It looks like Request doesn't have generics, although they're being used here.
The Request defined in @cloudflare/workers-types does have generics, so that should work, I think.
@asimpletune Would you be able to provide a reproduction repo that demonstrates the issue?
Hi! Id love to but I can't for a few weeks. But if you create a new project with the versions I listed above you will see the same results.
Although, the version I cited is when the issue was first introduced, so it should be present with wrangler 3.72.0 and its sibling worker types file.
Otherwise I can create a new issue when I'm available again, since the issue I brought up is only similar to the OP but not guaranteed to be the same.
I have encountered the same question
https://github.com/yunsii/cf-worker-status-page-pro/blob/7896301356277d72d9fc1ced420ad495547f3318/src/worker/index.ts#L24-L32
There's a couple of issues with your setup @yunsii:
- Firstly, you're hitting https://github.com/cloudflare/workerd/issues/1298 and will need to pin your
@types/nodeto an older version to preventRequestbeing overriden here;
"pnpm": {
"overrides": {
"@types/node": "20.8.3"
}
},
- Then you're also loading
DOMtypes in yourlibconfig in yourtsconfig, which also has its own version ofRequest. Remove this.
After this, the request type works fine in your example. 
If you have a need for DOM types, I'd recommend a different tsconfig.json for your worker, and your frontend.
For others experiencing this issue, I'd double check those two things - your lib in your tsconfig.json, and that @types/node is pinned to an old version, as per the previously linked issue.
@Cherry Thanks for your detailed explanation, it is a interesting issue 😄
hi all :) for anyone still running into this, please check out @Cherry 's followup comment above. if you are still having problems, please feel free to open a new issue referencing this one with a repro and any additional details and we will revisit and investigate. thanks!