Skip to content

Commit

Permalink
better typing of PaddingOptions and EaseToOptions (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanius authored Jul 11, 2021
1 parent 8a49205 commit c09ed83
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PaddingOptions>, eventData?: EventData): this;

rotateTo(bearing: number, options?: maplibregl.AnimationOptions, eventData?: EventData): this;

Expand Down Expand Up @@ -766,6 +766,8 @@ declare namespace maplibregl {
accessToken?: string;
}

export type RequireAtLeastOne<T> = { [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>; }[keyof T];

export type ResourceType =
| 'Unknown'
| 'Style'
Expand Down Expand Up @@ -1836,7 +1838,7 @@ declare namespace maplibregl {
}

export interface CameraForBoundsOptions extends CameraOptions {
padding?: number | PaddingOptions;
padding?: number | RequireAtLeastOne<PaddingOptions>;
offset?: PointLike;
maxZoom?: number;
}
Expand Down Expand Up @@ -1864,11 +1866,12 @@ declare namespace maplibregl {
*/
export interface EaseToOptions extends AnimationOptions, CameraOptions {
delayEndEvents?: number;
padding?: number | RequireAtLeastOne<PaddingOptions>;
}

export interface FitBoundsOptions extends maplibregl.FlyToOptions {
linear?: boolean;
padding?: number | maplibregl.PaddingOptions;
padding?: number | RequireAtLeastOne<PaddingOptions>;
offset?: maplibregl.PointLike;
maxZoom?: number;
maxDuration?: number;
Expand Down

0 comments on commit c09ed83

Please sign in to comment.