相关疑难解决方法(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 6-@ types / googlemaps / index.d.ts'不是一个模块

我刚刚在package.json文件中更新了一些软件包。然后npm install我跑了ng serve。但是我现在收到以下错误。

ERROR in ... File '.../node_modules/@types/googlemaps/index.d.ts' is not a module.
... error TS6137: Cannot import type declaration files. Consider importing 'googlemaps' instead of '@types/googlemaps'
Run Code Online (Sandbox Code Playgroud)

我在这里尝试了建议的解决方案- @ types / googlemaps / index.d.ts'不是/// <reference types="@types/googlemaps" />在我的component.ts文件顶部添加的模块,但是这不能解决我的问题,错误仍然存​​在。


package.json

{
  "name": "demo",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.7",
    "@angular/cdk": "^6.0.0", …
Run Code Online (Sandbox Code Playgroud)

google-maps typescript angular

9
推荐指数
2
解决办法
8819
查看次数

TypeScript错误:找不到命名空间'google'

我有项目angular-cli

〜根〜/ SRC/typings.json

{
  "globalDevDependencies": {
    "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654"
  },
  "globalDependencies": {
    "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
    "google.maps": "registry:dt/google.maps#3.20.0+20160914131659"
  }
}
Run Code Online (Sandbox Code Playgroud)

〜根〜/分型/ index.d.ts

/// <reference path="globals/angular-protractor/index.d.ts" />
/// <reference path="globals/es6-shim/index.d.ts" />
/// <reference path="globals/google.maps/index.d.ts" />
/// <reference path="globals/hammerjs/index.d.ts" />
/// <reference path="globals/jasmine/index.d.ts" />
/// <reference path="globals/selenium-webdriver/index.d.ts" />
Run Code Online (Sandbox Code Playgroud)

〜根〜/ SRC/tsconfig.json

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types",
      "../typings"
    ],
    "files": [ …
Run Code Online (Sandbox Code Playgroud)

typescript angular-cli typescript-typings angular

5
推荐指数
2
解决办法
1万
查看次数

如何从角度2的纬度,经度获取完整地址

我正在使用角度2-谷歌地图。
如何从带有typescript的angular2谷歌地图中的纬度,经度获取国家和地区等地址?

angular

1
推荐指数
2
解决办法
1万
查看次数