react-leaflet-search
react-leaflet-search copied to clipboard
Typing bug: Pick is not setting props as optional
Hello, thank you for providing us with this good library.
Right now we have the following problem:
Type '{ children: (info: SearchInfo) => Element; position: string; provider: string; showMarker: boolean; showPopup: boolean; zoom: number; closeResultsOnClick: true; openSearchOnLoad: boolean; onChange: (info: SearchInfo) => void; }' is missing the following properties from type 'Pick<any, "onChange" | "search" | "map" | "children" | "zoom" | "className" | "tabIndex" | "handler" | "provider" | "customProvider" | "providerOptions" | "openSearchOnLoad" | ... 8 more ... | "popUp">': search, map, className, tabIndex, and 8 more.
The solution that linter gives is to put all missing attributes as undefined:
<Search
position="topleft"
provider="OpenStreetMap"
showMarker={false}
showPopup={false}
zoom={7}
closeResultsOnClick
openSearchOnLoad={false}
onChange={(info: SearchInfo) => {
onChange(info.latLng);
}}
search={undefined}
map={undefined}
className={undefined}
tabIndex={undefined}
handler={undefined}
customProvider={undefined}
providerOptions={undefined}
inputPlaceholder={undefined}
mapStateModifier={undefined}
zoomPanOptions={undefined}
markerIcon={undefined}
popUp={undefined}
>
{(info: SearchInfo) => <Marker position={info?.latLng} />}
</Search>
But this is not the best way to solve it. It is not normal since you are importing all props with Pick
, so it should get all of them as optional:
/// <reference types="react" />
declare const _default: import("react").ComponentType<Pick<import("./ReactLeafletSearch").ReactLeafletSearchProps, "search" | "map" | "zoom" | "children" | "className" | "onChange" | "tabIndex" | "handler" | "provider" | "customProvider" | "providerOptions" | "openSearchOnLoad" | "closeResultsOnClick" | "inputPlaceholder" | "position" | "showMarker" | "showPopup" | "mapStateModifier" | "zoomPanOptions" | "markerIcon" | "popUp">>;
export default _default;
What's happening?