I'm using typescript 2.0 with the lastest ionic@RC.0
build process.
我正在使用最近的ionic@RC.0构建过程的typescript 2.0。
I installed the google-maps types like this:
我安装了google-maps类型,如下所示:
npm install @types/google-maps --save-dev --save-exact
npm install @ types / google-maps --save-dev --save-exact
and I'm trying to import some of the type definitions into my code like this
我正在尝试将一些类型定义导入到我的代码中
/// <reference types="google-maps" />
import { LatLng, LatLngBounds } from 'google-maps';
but I get this typescript error:
但我得到这个打字稿错误:
./node_modules/@types/google-maps/index.d.ts has no exported member 'LatLng'
./node_modules/@types/google-maps/index.d.ts没有导出成员'LatLng'
and if I look in the source, I actually find the definition in
如果我查看源代码,我实际上找到了定义
./node_modules/@types/google-maps/node_modules/@types/googlemaps/index.d.ts
./node_modules/@types/google-maps/node_modules/@types/googlemaps/index.d.ts
2 个解决方案
#1
1
You are checking the wrong declaration file. The one you are using is: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/google-maps/index.d.ts which does not expose LatLng.
您正在检查错误的声明文件。您使用的是:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/google-maps/index.d.ts,它不会公开LatLng。
The declaration file you linked to is: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/googlemaps/index.d.ts
您链接到的声明文件是:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/googlemaps/index.d.ts
googlemaps
vs google-maps
googlemaps vs google-maps
#2
-1
The import
only works for the current package, not its dependencies.
导入仅适用于当前包,而不适用于其依赖项。
So you need to import { LatLng, LatLngBounds } from 'googlemaps'
所以你需要从'googlemaps'导入{LatLng,LatLngBounds}
#1
1
You are checking the wrong declaration file. The one you are using is: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/google-maps/index.d.ts which does not expose LatLng.
您正在检查错误的声明文件。您使用的是:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/google-maps/index.d.ts,它不会公开LatLng。
The declaration file you linked to is: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/googlemaps/index.d.ts
您链接到的声明文件是:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/googlemaps/index.d.ts
googlemaps
vs google-maps
googlemaps vs google-maps
#2
-1
The import
only works for the current package, not its dependencies.
导入仅适用于当前包,而不适用于其依赖项。
So you need to import { LatLng, LatLngBounds } from 'googlemaps'
所以你需要从'googlemaps'导入{LatLng,LatLngBounds}