在編寫打字稿我得到一個錯誤:未知google.maps打字稿編譯錯誤的對象類型
src\app\foo.ts (129,25): Index signature of object type implicitly has an 'any' type. (7017)
以下行:
const tmode = google.maps['DirectionsTravelMode'].DRIVING;
google.maps。 DirectionsTravelMode不中,我使用typings install google.maps --save --ambient
我可以添加它,但它會丟失,當我結帳我的項目,並重新安裝分型安裝在我的分型文件存在。
這只是阻止我的構建成功的文件中的一個項目。讓打字稿忽略這一行最簡單的方法是什麼?我已經測試了代碼,並且它可以正常運行。
您可以將其轉換爲以下類型: tmode =( google).maps.DirectionsTravelMode.DRIVING; –
@CoreyAlix:有效!我曾嘗試const tmode:any = ...但它不起作用。請發表回答,以便我可以接受!謝謝 – chriskelly