Skip to content

Commit

Permalink
[@types/react-leaflet] Upgrade to cover v2.3.0 and v2.4.0 (Definitely…
Browse files Browse the repository at this point in the history
…Typed#37289)

* Cover v2.4.0 changes

This adds 2 additional properties to the Map component which can be seen
being documented in [this PR](PaulLeCam/react-leaflet#593).

The release notes for v2.4.0 can be viewed [here](https://github.com/PaulLeCam/react-leaflet/releases/tag/v2.4.0)

Signed-off-by: Jeroen Claassens <support@favware.tech>

* Cover v.2.3.0

V2.3.0 added a React hook. This PR covers the function as well as adding
a test that should test the hook.

- v2.3.0 Release Notes: https://github.com/PaulLeCam/react-leaflet/releases/tag/v2.3.0
- Primary Pull Request for v2.3.0: https://github.com/PaulLeCam/react-leaflet/pull/571/files

Signed-off-by: Jeroen Claassens <support@favware.tech>
  • Loading branch information
favna authored and Konch Roman committed Aug 13, 2019
1 parent 11a2140 commit ea7b087
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions types/react-leaflet/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Type definitions for react-leaflet 2.2
// Type definitions for react-leaflet 2.4
// Project: https://github.com/PaulLeCam/react-leaflet
// Definitions by: Dave Leaver <https://github.com/danzel>, David Schneider <https://github.com/davschne>, Yui T. <https://github.com/yuit>
// Definitions by: Dave Leaver <https://github.com/danzel>
// David Schneider <https://github.com/davschne>
// Yui T. <https://github.com/yuit>
// Jeroen Claassens <https://github.com/favna>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8

Expand Down Expand Up @@ -137,6 +140,8 @@ export class MapComponent<P extends MapComponentProps, E extends Leaflet.Evented

export interface MapProps extends MapEvents, Leaflet.MapOptions, Leaflet.LocateOptions, Leaflet.FitBoundsOptions {
animate?: boolean;
duration?: number;
noMoveStart?: boolean;
bounds?: Leaflet.LatLngBoundsExpression;
boundsOptions?: Leaflet.FitBoundsOptions;
children: Children;
Expand Down Expand Up @@ -464,3 +469,4 @@ export interface ContextProps {
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

export function withLeaflet<T extends ContextProps>(WrappedComponent: React.ComponentType<T>): React.ComponentType<Omit<T, 'leaflet'>>;
export function useLeaflet(): LeafletContext;
6 changes: 5 additions & 1 deletion types/react-leaflet/react-leaflet-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
ZoomControl,
LeafletProvider,
withLeaflet,
Viewport
Viewport,
useLeaflet,
} from 'react-leaflet';
const { BaseLayer, Overlay } = LayersControl;

Expand Down Expand Up @@ -813,3 +814,6 @@ class CustomPolygon extends Path<PolygonProps, L.Polygon> {
}
}
const leafletComponent = withLeaflet<PolygonProps>(CustomPolygon);

// $ExpectType LeafletContext
useLeaflet();

0 comments on commit ea7b087

Please sign in to comment.