Skip to content

Map.setStyle() options type doesn't match docs #13312

Open
@andrewfergelbotlink

Description

@andrewfergelbotlink

The Map.setStyle() function's options param has a type of SetStyleOptions, which is defined in src/ui/map.ts as follows:

export type SetStyleOptions = {
    diff?: boolean;
    config?: {
        [key: string]: ConfigSpecification;
    };
    localFontFamily: StyleOptions['localFontFamily'];
    localIdeographFontFamily: StyleOptions['localIdeographFontFamily'];
};

However, the documentation (https://docs.mapbox.com/mapbox-gl-js/api/map/#map#setstyle) doesn't specify a required localFontFamily field. The documentation also states that localIdeographFontFamily has a default value, which seems to suggest that it shouldn't be a required field.

mapbox-gl-js version: 3.7.0

browser: N/A

Steps to Trigger Behavior

  1. Create a new Node project and include mapbox-gl 3.7.0 in package.json
  2. In a Typescript file, import mapboxgl and create a new Map object
  3. Call setStyle() on the map object and pass it an empty object for the options param

Expected Behavior

Typescript should not show any errors.

Actual Behavior

Typescript shows the following error:

Argument of type '{}' is not assignable to parameter of type 'SetStyleOptions'.
  Type '{}' is missing the following properties from type 'SetStyleOptions': localFontFamily, localIdeographFontFamily

Metadata

Metadata

Assignees

No one assigned

    Labels

    typesIssues related to the public TypeScript typings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions