我在最新的ionic@RC.0构建过程中使用TypeScript2.0。
我安装了如下的google-maps类型:
npm install @types/google-maps --save-dev --save-exact
我正在尝试将一些类型定义导入到我的代码中,如下所示
/// <reference types="google-maps" />
import { LatLng, LatLngBounds } from 'google-maps';但是我得到了这个打字错误:
./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
发布于 2018-10-27 19:02:32
在项目根文件夹的tsconfig.json文件中添加对types包的引用:
"types": [
"google-maps"
]不要在源文件中导入任何内容,类型是全局定义的。
发布于 2017-11-29 14:02:35
import仅适用于当前包,而不适用于其依赖项。
所以你需要import { LatLng, LatLngBounds } from 'googlemaps'
发布于 2017-12-25 15:16:27
您检查了错误的声明文件。您正在使用的是:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/google-maps/index.d.ts,它不公开LatLng。
您链接到的声明文件是:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/googlemaps/index.d.ts
googlemaps vs google-maps
https://stackoverflow.com/questions/39818429
复制相似问题