Add generic to use-control for inferring return type (#1739)

This commit is contained in:
Max Nowack 2022-02-21 19:55:20 +01:00 committed by GitHub
parent 4a73faaeea
commit 554e03eaa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,8 +7,8 @@ type ControlOptions = {
position?: ControlPosition;
};
export default function useControl(
onCreate: (context: MapContextValue) => IControl,
export default function useControl<T extends IControl>(
onCreate: (context: MapContextValue) => T,
onRemove?: ((context: MapContextValue) => void) | ControlOptions,
opts?: ControlOptions
) {