Open alirezas opened 8 months ago
Could you please describe the context of the code that you're getting this error from?
Also getting this TypeScript error. Just set it up on my NextJS project with next-pwa, window.workbox
does not have any type definition
You can install this package: @types/workbox-window. Then, you should create a folder named @types
and a file named workbox.d.ts
with the following content:
import { Workbox } from 'workbox-window';
declare global {
interface Window {
workbox: Workbox
}
}
It's works for me:
Im still getting the same error in the ts-config and i did what you had suggested @raphaeldevs
Can you show the error? @LyghtCode
Summary
How can I fix this typescript issue? I'm getting this error in the code below:
if ( typeof window !== "undefined" && "serviceWorker" in navigator && window.workbox !== undefined )
Property 'workbox' does not exist on type 'Window & typeof globalThis'.ts(2339)
Versions
next-pwa
: ^5.6.0next
: 13.5.6