Map.setStyle() options type doesn't match docs
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
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
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/ui/map.ts, where SetStyleOptions is defined, and compare its required fields with the Map.setStyle() API documentation. Confirm the type and documentation agree and that passing an empty options object in a TypeScript project produces no type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100