diff --git a/CHANGELOG.md b/CHANGELOG.md index 2901bfec8e..468e1a3d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### 🐞 Bug fixes +- Correct declared return type of `Map.getLayer()` and `Style.getLayer()` to be `StyleLayer | undefined` to match the documentation. - _...Add new stuff here..._ ## 3.3.0 diff --git a/src/style/style.ts b/src/style/style.ts index 5777131458..9b7e4ef180 100644 --- a/src/style/style.ts +++ b/src/style/style.ts @@ -994,7 +994,7 @@ export class Style extends Evented { * @param id - id of the desired layer * @returns a layer, if one with the given `id` exists */ - getLayer(id: string): StyleLayer { + getLayer(id: string): StyleLayer | undefined { return this._layers[id]; } diff --git a/src/ui/map.ts b/src/ui/map.ts index 7220bd9811..d9e51276c1 100644 --- a/src/ui/map.ts +++ b/src/ui/map.ts @@ -2475,7 +2475,7 @@ export class Map extends Camera { * @see [Filter symbols by toggling a list](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers/) * @see [Filter symbols by text input](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers-by-input/) */ - getLayer(id: string): StyleLayer { + getLayer(id: string): StyleLayer | undefined { return this.style.getLayer(id); }