-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cloudflare): runtime types for Cloudflare caches #8782
fix(cloudflare): runtime types for Cloudflare caches #8782
Conversation
🦋 Changeset detectedLatest commit: 2d64c2d The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I think this would affect client-side types as well. It's fine to intentionally do it as a user, but idk if the adapter should do it across the board. Users might find that surprising. I'll let @alexanderniebuhr decide. You should know the cloudflare adapter is in the middle of a migration to https://github.com/withastro/adapters. Hopefully, it will be done by the end of the week. This PR would probably be merged in that repo. |
Oh yeah this was actually what I wanted to clarify beforehand, maybe I did not make myself clear. Why wouldn't something like this work? export interface DirectoryRuntime<T extends object = object> {
runtime: {
waitUntil: (promise: Promise<any>) => void;
env: EventContext<unknown, string, unknown>['env'] & T;
cf: CFRequest['cf'];
- caches: typeof caches;
+ caches: CacheStorage;
} runtime: {
waitUntil: (promise: Promise<any>) => {
context.waitUntil(promise);
},
env: env,
cf: request.cf,
- caches: caches,
+ caches: caches as unknown as CacheStorage,
} |
@alexanderniebuhr that should definitely work, I just did |
Also, does this repo qualify for Hacktoberfest? No issues if it doesn't, just curious. |
* fix cachestorage reference in cloudflare integration * add cachestorage to serverdirectorymode * add changeset * remove global caches type * update unlucky-avocados-brake.md
Changes
CacheStorage
type from @cloudflare/workers-types, to override defaultdom.d.ts
cache types, which do not match.Testing
Typechange only, types compile correctly.
Docs
This update clarifies types for Runtime Cache, which afaict isn't documented.