我想在Angular项目中使用Google Maps API,因此我使用了以下两个命令来安装npm软件包:
npm install @agm/core --save-dev
npm install @types/googlemaps --save-dev
我将此行添加到我的组件中:
import {} from "@types/googlemaps";
但是我在VS Code中看到了这两个错误:
[ts] File 'h:/Angular Projects/Breakfast/client/breakfast/node_modules/@types/googlemaps/index.d.ts' is not a module.
[ts] Cannot import type declaration files. Consider importing 'googlemaps' instead of '@types/googlemaps'.
我添加了这些行
"types": ["googlemaps"]
"moduleResolution": "node"
到tsconfig.json和tsconfig.spec.json,但仍然没有运气。在Chrome开发者工具上,我看到以下错误:
Error: Uncaught (in promise): TypeError: Cannot read property 'Autocomplete' of undefined
TypeError: Cannot read property 'Autocomplete' of undefined
Angular版本6打字稿版本2.9.2
我也尝试过Angular 5。