相关疑难解决方法(0)

@ types/googlemaps/index.d.ts'不是模块

我想在我的Angular项目中使用Google Maps API,因此我使用这两个命令来安装npm包:

npm install @agm/core --save-dev
npm install @types/googlemaps --save-dev
Run Code Online (Sandbox Code Playgroud)

我将此行添加到我的组件中:

import {} from "@types/googlemaps";
Run Code Online (Sandbox Code Playgroud)

但是我在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'.
Run Code Online (Sandbox Code Playgroud)

我添加了这些行

"types": ["googlemaps"]
"moduleResolution": "node"
Run Code Online (Sandbox Code Playgroud)

到tsconfig.json和tsconfig.spec.json,但仍然没有运气.在Chrome开发工具上,我看到以下错误:

Error: Uncaught (in promise): TypeError: Cannot read property 'Autocomplete' of undefined
TypeError: Cannot read property 'Autocomplete' of undefined
Run Code Online (Sandbox Code Playgroud)

角度版本6打字稿版本2.9.2

我也尝试过Angular 5.

typescript angular-cli angular angular-cli-v6

54
推荐指数
7
解决办法
3万
查看次数

标签 统计

angular ×1

angular-cli ×1

angular-cli-v6 ×1

typescript ×1