cloudflare / workers-types

TypeScript type definitions for authoring Cloudflare Workers.
BSD 3-Clause "New" or "Revised" License
359 stars 89 forks source link

RequestInit is missing some properties like 'cache' #290

Closed seeekr closed 1 year ago

seeekr commented 2 years ago

Here's a commit showing another project updating their types in similar fashion:

https://github.com/nodejs/undici/pull/1199/commits/6aa8aadcbc023bb42898b2f4b76c2501bac057cc

Would appreciate an update :) (Might send a PR if I get around to it, seems easy enough to do it!)

seeekr commented 2 years ago

Hmm, it seems that this is intentional, as in the CF workers Request API doesn't actually support changing how the fetch() call should interact with the cache. That is a bummer... It's kinda hard to reliably navigate and use the workers APIs with what feels like so many limitations and things you have to pay special attention to and understand in detail before it'll do the simple things you need it to do...

And though the documentation is quite good overall, I feel like I'm stumbling waaay too much still. Might just be me, don't know.

KianNH commented 2 years ago

The Fetch Web API has a few properties or options that aren’t relevant to the server-side context of Workers so they’re not implemented - like mode, credentials, etc

seeekr commented 2 years ago

@KianNH Thanks, omitting those makes sense. But what about the cache property specifically? It would be pretty great to be able to tell CF how it should behave regarding caching for a particular fetch() call. This question might be a product question, but maybe you (or someone else) knows what the current thinking here is, and/or if this particular property just has been forgotten about in some fashion but there's no reason not to implement and provide it?

Thanks again!