From c09ed83f2324fabd0c80c8be1d0db9cec814232f Mon Sep 17 00:00:00 2001 From: Jakub Kraft Date: Sun, 11 Jul 2021 20:10:01 +0200 Subject: [PATCH] better typing of PaddingOptions and EaseToOptions (#202) --- src/index.d.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 4afb3f14bc..e6adda22f4 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -479,7 +479,7 @@ declare namespace maplibregl { * // Sets a left padding of 300px, and a top padding of 50px * map.setPadding({ left: 300, top: 50 }); */ - setPadding(padding: PaddingOptions, eventData?: EventData): this; + setPadding(padding: RequireAtLeastOne, eventData?: EventData): this; rotateTo(bearing: number, options?: maplibregl.AnimationOptions, eventData?: EventData): this; @@ -766,6 +766,8 @@ declare namespace maplibregl { accessToken?: string; } + export type RequireAtLeastOne = { [K in keyof T]-?: Required> & Partial>>; }[keyof T]; + export type ResourceType = | 'Unknown' | 'Style' @@ -1836,7 +1838,7 @@ declare namespace maplibregl { } export interface CameraForBoundsOptions extends CameraOptions { - padding?: number | PaddingOptions; + padding?: number | RequireAtLeastOne; offset?: PointLike; maxZoom?: number; } @@ -1864,11 +1866,12 @@ declare namespace maplibregl { */ export interface EaseToOptions extends AnimationOptions, CameraOptions { delayEndEvents?: number; + padding?: number | RequireAtLeastOne; } export interface FitBoundsOptions extends maplibregl.FlyToOptions { linear?: boolean; - padding?: number | maplibregl.PaddingOptions; + padding?: number | RequireAtLeastOne; offset?: maplibregl.PointLike; maxZoom?: number; maxDuration?: number;