Skip to content

Commit 0c09e28

Browse files
authored
Merge pull request #272 from gburgett/typedefs
Add Typescript definitions
2 parents e4de0c7 + c190e8f commit 0c09e28

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed

index.d.ts

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import 'googlemaps'
2+
import * as React from 'react'
3+
4+
interface IGoogleApiOptions {
5+
apiKey: string,
6+
libraries?: string[],
7+
client?: string,
8+
url?: string,
9+
version?: string,
10+
language?: string,
11+
region?: string,
12+
LoadingContainer?: any
13+
}
14+
type GoogleApiOptionsFunc = (props: any) => IGoogleApiOptions
15+
16+
type Omit<T1, T2> = Pick<T1, Exclude<keyof T1, keyof T2>>
17+
18+
export type GoogleAPI = typeof google
19+
export function GoogleApiWrapper(opts: IGoogleApiOptions | GoogleApiOptionsFunc):
20+
<TProps extends IProvidedProps>(ctor: React.ComponentType<TProps>) => React.ComponentType<Omit<TProps, IProvidedProps>>
21+
22+
export interface IProvidedProps {
23+
google: GoogleAPI
24+
loaded?: boolean
25+
}
26+
27+
type mapEventHandler = (mapProps?: IMapProps, map?: google.maps.Map, event?) => any
28+
29+
export interface IMapProps extends google.maps.MapOptions {
30+
google: GoogleAPI
31+
loaded?: boolean
32+
33+
bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral
34+
centerAroundCurrentLocation?: boolean
35+
initialCenter?: google.maps.LatLngLiteral
36+
37+
visible?: boolean
38+
39+
onReady?: mapEventHandler
40+
onClick?: mapEventHandler
41+
onDragend?: mapEventHandler
42+
onRecenter?: mapEventHandler
43+
onBoundsChanged?: mapEventHandler
44+
onCenterChanged?: mapEventHandler
45+
onDblclick?: mapEventHandler
46+
onDragstart?: mapEventHandler
47+
onHeadingChange?: mapEventHandler
48+
onIdle?: mapEventHandler
49+
onMaptypeidChanged?: mapEventHandler
50+
onMousemove?: mapEventHandler
51+
onMouseover?: mapEventHandler
52+
onMouseout?: mapEventHandler
53+
onProjectionChanged?: mapEventHandler
54+
onResize?: mapEventHandler
55+
onRightclick?: mapEventHandler
56+
onTilesloaded?: mapEventHandler
57+
onTiltChanged?: mapEventHandler
58+
onZoomChanged?: mapEventHandler
59+
}
60+
61+
type markerEventHandler = (props?: IMarkerProps, marker?: google.maps.Marker, event?) => any
62+
63+
export interface IMarkerProps extends Partial<google.maps.MarkerOptions> {
64+
mapCenter?: google.maps.LatLng | google.maps.LatLngLiteral
65+
66+
onClick?: markerEventHandler
67+
onMouseover?: markerEventHandler
68+
}
69+
70+
export class Map extends React.Component<IMapProps, any> {
71+
72+
}
73+
74+
export class Marker extends React.Component<IMarkerProps, any> {
75+
76+
}
77+
78+
export class Polygon extends React.Component<any, any> {
79+
80+
}
81+
82+
export class Polyline extends React.Component<any, any> {
83+
84+
}
85+
86+
export class Circle extends React.Component<any, any> {
87+
88+
}
89+
90+
export interface IInfoWindowProps extends Partial<google.maps.InfoWindowOptions> {
91+
google: typeof google
92+
map: google.maps.Map
93+
marker: google.maps.Marker
94+
95+
mapCenter?: google.maps.LatLng | google.maps.LatLngLiteral
96+
visible?: boolean
97+
98+
}
99+
100+
export class InfoWindow extends React.Component<IInfoWindowProps, any> {
101+
102+
}

package-lock.json

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"files": [
1616
"dist"
1717
],
18+
"types": "index.d.ts",
1819
"scripts": {
1920
"prepublish": "./scripts/prepublish.sh",
2021
"preversion": ". ./scripts/prepublish.sh",
@@ -28,6 +29,8 @@
2829
"test-watch": "npm run testonly -- --watch --watch-extensions js"
2930
},
3031
"devDependencies": {
32+
"@types/googlemaps": "^3",
33+
"@types/react": "^15.0.0",
3134
"autoprefixer": "^6.3.6",
3235
"babel-cli": "^6.7.7",
3336
"babel-core": "^6.7.4",

0 commit comments

Comments
 (0)