diff --git a/src/ol/Feature.js b/src/ol/Feature.js index 4bfb5401de..4ab77b4393 100644 --- a/src/ol/Feature.js +++ b/src/ol/Feature.js @@ -11,7 +11,7 @@ import {listen, unlistenByKey} from './events.js'; */ /** - * @typedef {Feature|import("./render/Feature.js").default} FeatureLike + * @typedef {Feature|import("./render/Feature.js").default} FeatureLike */ /*** @@ -70,7 +70,7 @@ import {listen, unlistenByKey} from './events.js'; * ``` * * @api - * @template {import("./geom/Geometry.js").default} Geometry + * @template {import("./geom/Geometry.js").default} [Geometry=import("./geom/Geometry.js").default] */ class Feature extends BaseObject { /** diff --git a/src/ol/format/KML.js b/src/ol/format/KML.js index 993e14196b..4c87601b00 100644 --- a/src/ol/format/KML.js +++ b/src/ol/format/KML.js @@ -1007,8 +1007,7 @@ function createFeatureStyleFunction( if (drawName) { const geometry = feature.getGeometry(); if (geometry) { - const type = geometry.getType(); - if (type === GeometryType.GEOMETRY_COLLECTION) { + if (geometry instanceof GeometryCollection) { multiGeometryPoints = geometry .getGeometriesArrayRecursive() .filter(function (geometry) { @@ -1020,6 +1019,7 @@ function createFeatureStyleFunction( }); drawName = multiGeometryPoints.length > 0; } else { + const type = geometry.getType(); drawName = type === GeometryType.POINT || type === GeometryType.MULTI_POINT; } diff --git a/src/ol/format/Polyline.js b/src/ol/format/Polyline.js index f0c9ae1820..b87c162be1 100644 --- a/src/ol/format/Polyline.js +++ b/src/ol/format/Polyline.js @@ -110,7 +110,7 @@ class Polyline extends TextFeature { } /** - * @param {import("../Feature.js").default} feature Features. + * @param {import("../Feature.js").default} feature Features. * @param {import("./Feature.js").WriteOptions} [opt_options] Write options. * @protected * @return {string} Text. @@ -126,7 +126,7 @@ class Polyline extends TextFeature { } /** - * @param {Array} features Features. + * @param {Array>} features Features. * @param {import("./Feature.js").WriteOptions} [opt_options] Write options. * @protected * @return {string} Text. diff --git a/src/ol/interaction/Draw.js b/src/ol/interaction/Draw.js index f01e3e1a9c..64c7be6c98 100644 --- a/src/ol/interaction/Draw.js +++ b/src/ol/interaction/Draw.js @@ -421,7 +421,7 @@ class Draw extends PointerInteraction { /** * Sketch feature. - * @type {Feature} + * @type {Feature} * @private */ this.sketchFeature_ = null; @@ -1022,7 +1022,7 @@ class Draw extends PointerInteraction { /** * Stop drawing without adding the sketch feature to the target layer. - * @return {Feature} The sketch feature (or null if none). + * @return {Feature} The sketch feature (or null if none). * @private */ abortDrawing_() { diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index 0807ea0da4..ebd4aba6c6 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -253,7 +253,7 @@ class Modify extends PointerInteraction { /** * Editing vertex. - * @type {Feature} + * @type {Feature} * @private */ this.vertexFeature_ = null; diff --git a/src/ol/layer/Layer.js b/src/ol/layer/Layer.js index 87dce260ca..0c55fdc460 100644 --- a/src/ol/layer/Layer.js +++ b/src/ol/layer/Layer.js @@ -25,7 +25,7 @@ import {listen, unlistenByKey} from '../events.js'; */ /** - * @template {import("../source/Source.js").default} SourceType + * @template {import("../source/Source.js").default} [SourceType=import("../source/Source.js").default] * @typedef {Object} Options * @property {string} [className='ol-layer'] A CSS class name to set to the layer element. * @property {number} [opacity=1] Opacity (0, 1). @@ -93,8 +93,8 @@ import {listen, unlistenByKey} from '../events.js'; * @fires import("../render/Event.js").RenderEvent#prerender * @fires import("../render/Event.js").RenderEvent#postrender * - * @template {import("../source/Source.js").default} SourceType - * @template {import("../renderer/Layer.js").default} RendererType + * @template {import("../source/Source.js").default} [SourceType=import("../source/Source.js").default] + * @template {import("../renderer/Layer.js").default} [RendererType=import("../renderer/Layer.js").default] * @api */ class Layer extends BaseLayer { diff --git a/src/ol/renderer/webgl/TileLayer.js b/src/ol/renderer/webgl/TileLayer.js index 2af3a33b3d..efce2e56cb 100644 --- a/src/ol/renderer/webgl/TileLayer.js +++ b/src/ol/renderer/webgl/TileLayer.js @@ -96,8 +96,9 @@ function getRenderExtent(frameState, extent) { fromUserExtent(layerState.extent, frameState.viewState.projection) ); } - const source = - /** {import("../../source/Tile.js").default} */ layerState.layer.getRenderSource(); + const source = /** @type {import("../../source/Tile.js").default} */ ( + layerState.layer.getRenderSource() + ); if (!source.getWrapX()) { const gridExtent = source .getTileGridForProjection(frameState.viewState.projection) diff --git a/src/ol/source/Cluster.js b/src/ol/source/Cluster.js index 66fc33e4fe..5621a33d7f 100644 --- a/src/ol/source/Cluster.js +++ b/src/ol/source/Cluster.js @@ -115,7 +115,7 @@ class Cluster extends VectorSource { this.geometryFunction = options.geometryFunction || function (feature) { - const geometry = feature.getGeometry(); + const geometry = /** @type {Point} */ (feature.getGeometry()); assert(geometry.getType() == GeometryType.POINT, 10); // The default `geometryFunction` can only handle `Point` geometries return geometry; }; diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index 32d6cf6644..77f4f61bd8 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -34,7 +34,7 @@ import {xhr} from '../featureloader.js'; * @classdesc * Events emitted by {@link module:ol/source/Vector} instances are instances of this * type. - * @template {import("../geom/Geometry.js").default} Geometry + * @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default] */ export class VectorSourceEvent extends Event { /** @@ -170,7 +170,7 @@ export class VectorSourceEvent extends Event { * * @fires VectorSourceEvent * @api - * @template {import("../geom/Geometry.js").default} Geometry + * @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default] */ class VectorSource extends Source { /** @@ -299,9 +299,15 @@ class VectorSource extends Source { let collection, features; if (Array.isArray(options.features)) { - features = options.features; + features = + /** @type {Array>} */ ( + options.features + ); } else if (options.features) { - collection = options.features; + collection = + /** @type {Collection>} */ ( + options.features + ); features = collection.getArray(); } if (!useSpatialIndex && collection === undefined) {