Closed FleetAdmiralJakob closed 10 months ago
I wouldn't trust CodeSandbox's IDE to be honest.
It couldn't even resolve react
or next
...
This example works fine in VSCode though.
IntelliJ gives the same error
@FleetAdmiralJakob I don't own IntelliJ, so I can't really help you with that. I think how we are doing it is correct. One thing I'd like to check with you though, would adding "type": "module"
to your package.json fix it?
"type": "module"
helps not.
"type": "module"
breaks the next config
Errors still there.
It also breaks dozen of eslint rules. But I think I can disable them with a dozen of the ugly eslint disable rules but the typescript errors remain.
And you can't build it. It just runs in the dev version.
@FleetAdmiralJakob That's really weird. This is straight up a "It works on my machine ™️" moment I have to tell you that... Wondering what could cause this. I will investigate tomorrow!
@FleetAdmiralJakob still unable to reproduce the error... I'd like to know your package.json and tsconfig.json if that's possible :)
@FleetAdmiralJakob you don't have "@ducanh2912/next-pwa/workbox"
, which declares window.workbox
, in your tsconfig.json's "compilerOptions.types"
. Try adding that to see if it helps.
Yes, this solves the problem with the TS Error but I still have one ESLint error:
ESLint: Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void
operator.(@typescript-eslint/no-floating-promises)
@FleetAdmiralJakob the error message states itself clearly. That function returns a Promise, and the lint rule wants it voided or handled properly. The fastest, most concise way of fixing it is to add the void
operator before the function call.
Provide environment information
next: 14.0.4, "@ducanh2912/next-pwa": "^10.0.0",
Link to reproduction - Issues with a link to complete (but minimal) reproduction code help us address them faster
https://codesandbox.io/p/devbox/github/DuCanhGH/next-pwa/blob/master/examples/lifecycle
To reproduce
try to use window.workbox
Describe the bug
There is no property workbox on window.
TS2339: Property workbox does not exist on type Window & typeof globalThis
Expected behavior
No type error
Screenshots (if relevant)
No response
Additional information (if relevant)
No response