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

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

Open
andrewfergelbotlink opened this issue Oct 28, 2024 · 0 comments
Open

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

andrewfergelbotlink opened this issue Oct 28, 2024 · 0 comments

Comments

@andrewfergelbotlink
Copy link

andrewfergelbotlink commented Oct 28, 2024

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
@andrewfergelbotlink andrewfergelbotlink changed the title map.setStyle() options type doesn't match docs Map.setStyle() options type doesn't match docs Oct 30, 2024
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