我正在使用最近的ionic@RC.0构建过程的typescript 2.0 .
我安装了google-maps类型,如下所示:
npm install @types/google-maps --save-dev --save-exact
我正在尝试将一些类型定义导入到我的代码中
/// <reference types="google-maps" />
import { LatLng, LatLngBounds } from 'google-maps';
Run Code Online (Sandbox Code Playgroud)
但我得到这个打字稿错误:
./node_modules/@types/google-maps/index.d.ts has no exported member 'LatLng'
如果我查看源代码,我实际上找到了定义
./node_modules/@types/google-maps/node_modules/@types/googlemaps/index.d.ts
Rop*_*pez 10
tsconfig.json在项目根文件夹中的文件中添加对 types 包的引用:
"types": [
"google-maps"
]
Run Code Online (Sandbox Code Playgroud)
不要在源文件中导入任何内容,类型是全局定义的。
仅import适用于当前包,不适用于其依赖项。
所以你需要import { LatLng, LatLngBounds } from 'googlemaps'
| 归档时间: |
|
| 查看次数: |
19702 次 |
| 最近记录: |