Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing bug: Pick is not setting props as optional #52

Open
SalahAdDin opened this issue Jun 17, 2022 · 0 comments
Open

Typing bug: Pick is not setting props as optional #52

SalahAdDin opened this issue Jun 17, 2022 · 0 comments

Comments

@SalahAdDin
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant