类型“Window & typeof globalThis”上不存在属性“xxxx”

3,091 阅读1分钟

最简单就是把 window 断言成 any 绕过去:

(window as any).webkitIndexedDB
(window as any).mozIndexedDB

更好的方式是在某个*.d.ts文件中(TypeScript Declaration File)声明下:

declare interface Window {
  webkitIndexedDB: any,
  mozIndexedDB:any,
}