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
u0
u0OP•3y ago
My tsconfig is pretty simple:
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"lib": [
"ES2020"
],
"types": [
"@cloudflare/workers-types"
]
}
}
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"lib": [
"ES2020"
],
"types": [
"@cloudflare/workers-types"
]
}
}
The suggestion mentioned here https://discord.com/channels/595317990191398933/779390076219686943/1014614267858788412 to switch lib did not resolve my issue 😥
u0
u0OP•3y ago
Unfortunately that does not resolve my issue either
Hello, I’m Allie!
Try reloading VSCode. Sometimes the TS server gets stuck…
u0
u0OP•3y ago
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
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Hello, I’m Allie!
I’ll try to recreate it in a bit
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Hello, I’m Allie!
Ok, found your issue... Do you want it as a PR to your repo?
u0
u0OP•3y ago
Whatever is easiest, maybe type out here so other people can find in discord search?
Hello, I’m Allie!
So the main issue is that you didn't have an include field in your tsconfig, which applies the types to the directory.
u0
u0OP•3y ago
not sure I follow, not having an include defined within the tsconfig should have the following behaviour:
Specifies a list of glob patterns that match files to be included in compilation. If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. Requires TypeScript version 2.0 or later.
Specifies a list of glob patterns that match files to be included in compilation. If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. Requires TypeScript version 2.0 or later.
I added an "include": ["**/*"] but still see a type error within VSCode
Hello, I’m Allie!
GitHub
GitHub - helloimalastair/u0.vc at codespace-9c53
Contribute to helloimalastair/u0.vc development by creating an account on GitHub.
u0
u0OP•3y ago
Checked out your changes, restarted VSCode
Hello, I’m Allie!
What node version are you on? Also, try a clean node_modules install
u0
u0OP•3y ago
node --version
v16.15.1
node --version
v16.15.1
Okay, will remove node_modules and reinstall everything
Hello, I’m Allie!
Probably isn't the issue, but it is working on v19.0.0. Let me try downgrading...
u0
u0OP•3y ago
I upgraded to node 18.12.0 and 19.0.0 but I still see this error 🤷
Hello, I’m Allie!
Can you replicate it on a different device? I got the issue to pop up, but only before I changed the tsconfig.
u0
u0OP•3y ago
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 🥂
Hello, I’m Allie!
No problem!
Want results from more Discord servers?
Add your server