Last active
August 23, 2018 02:45
-
-
Save gwillz/9498267353770cbd121fe3aabc5cec68 to your computer and use it in GitHub Desktop.
React-Leaflet type definitions for v2.0 (extension for existing @types/react-leaflet)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react' | |
import * as L from 'leaflet' | |
import 'react-leaflet' | |
declare module 'react-leaflet' { | |
export interface LeafletContext { | |
map?: L.Map, | |
pane?: string, | |
layerContainer?: LayerContainer, | |
popupContainer?: L.Layer, | |
} | |
export class LeafletConsumer extends React.Component<React.ConsumerProps<LeafletContext>> {} | |
export class LeafletProvider extends React.Component<React.ProviderProps<LeafletContext>> {} | |
export type WrappedProps = { | |
leaflet: LeafletContext; | |
} | |
// https://stackoverflow.com/questions/48215950/exclude-property-from-type | |
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | |
export function withLeaflet<T extends WrappedProps>(WrappedComponent: React.ComponentType<T>): React.ComponentType<Omit<T, 'leaflet'>>; | |
export interface MapLayer { | |
contextValue?: LeafletContext; | |
} | |
export interface Map { | |
contextValue?: LeafletContext; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment