如何让Google Closure Compiler理解`caches`变量(CacheStorage)?

问题描述 投票:0回答:1

如果我使用 caches 在我的服务工作者代码中,Google Closure Compiler(用高级优化模式启动)会告诉我。

varwwwhtmlpersootraSitewebjssw_viaTypescript.js:79: ERROR - [JSC_UNDEFINED_VARIABLE] > 变量caches is undeclared })(caches); ^^^^^^^^

1个错误,0个警告。

我至今使用的一个变通方法是......。我把 window.caches 所以Google Closure Compiler成功编译,但如果我让这段代码,浏览器会告诉我。

sw.js:18 Uncaught ReferenceError: window is not defined(未发现引用错误)。

所以我换了 window.cachescaches 在之后由Google Closure Compiler编译的代码中,但是......每次都要这样做很烦人。

有没有更干净的方法来处理它?

service-worker google-closure-compiler cachestorage
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.