Property 'default' does not exist on type 'CacheStorage'
I am seeing a typescript error for
let response = await caches.default.match(req);
which shows Property 'default' does not exist on type 'CacheStorage'. ts(2339)
It seems to be using the CacheStorage
definition from /node_modules/typescript/lib/lib.dom.d.ts
instead of @cloudflare/workers-types
21 Replies
My tsconfig is pretty simple:
The suggestion mentioned here https://discord.com/channels/595317990191398933/779390076219686943/1014614267858788412 to switch lib did not resolve my issue 😥
Unfortunately that does not resolve my issue either
Try reloading VSCode. Sometimes the TS server gets stuck…
Issue still persists with a reload of VSCode, restarted my language servers as well. Maybe it would be helpful to look at my repo?
Specific lines are at https://github.com/udiaca/u0.vc/blob/e7b61c6a9a4626aa7ba32cbe2a8748db69bd5839/functions/opt/%5B%5Bpath%5D%5D.ts#L5-L14 and https://github.com/udiaca/u0.vc/blob/investigate-caches-default/src/utils/caches.ts
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I’ll try to recreate it in a bit
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Ok, found your issue...
Do you want it as a PR to your repo?
Whatever is easiest, maybe type out here so other people can find in discord search?
So the main issue is that you didn't have an
include
field in your tsconfig
, which applies the types to the directory.not sure I follow, not having an include defined within the
tsconfig
should have the following behaviour:
I added an "include": ["**/*"]
but still see a type error within VSCodeTry pulling this one: https://github.com/helloimalastair/u0.vc/tree/codespace-9c53
GitHub
GitHub - helloimalastair/u0.vc at codespace-9c53
Contribute to helloimalastair/u0.vc development by creating an account on GitHub.
Checked out your changes, restarted VSCode
What node version are you on? Also, try a clean node_modules install
Okay, will remove node_modules and reinstall everything
Probably isn't the issue, but it is working on
v19.0.0
.
Let me try downgrading...I upgraded to node
18.12.0
and 19.0.0
but I still see this error 🤷Can you replicate it on a different device? I got the issue to pop up, but only before I changed the
tsconfig
.Hmmm, with your tsconfig changes and the following devcontainer,
"image":"mcr.microsoft.com/devcontainers/typescript-node:16-bullseye"
the error goes away. Wonder what's up with my environment. Thank you for all of your help @HardAtWork 🥂No problem!