From 217230172b592629aa801a23f29d647826e796cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sat, 30 Jul 2022 02:03:31 +0200 Subject: [PATCH] Make VectorSource Options generic --- src/ol/source/Vector.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index 12b283c4a7..426ef36aa2 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -72,7 +72,7 @@ export class VectorSourceEvent extends Event { /** * @typedef {Object} Options * @property {import("./Source.js").AttributionLike} [attributions] Attributions. - * @property {Array|Collection} [features] + * @property {Array>|Collection>} [features] * Features. If provided as {@link module:ol/Collection~Collection}, the features in the source * and the collection will stay in sync. * @property {import("../format/Feature.js").default} [format] The feature format used by the XHR @@ -159,6 +159,7 @@ export class VectorSourceEvent extends Event { * @property {boolean} [wrapX=true] Wrap the world horizontally. For vector editing across the * -180° and 180° meridians to work properly, this should be set to `false`. The * resulting geometry coordinates will then exceed the world bounds. + * @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default] */ /** @@ -173,7 +174,7 @@ export class VectorSourceEvent extends Event { */ class VectorSource extends Source { /** - * @param {Options} [opt_options] Vector source options. + * @param {Options} [opt_options] Vector source options. */ constructor(opt_options) { const options = opt_options || {}; @@ -296,17 +297,17 @@ class VectorSource extends Source { */ this.featuresCollection_ = null; - let collection, features; + /** @type {Collection>} */ + let collection; + /** @type {Array>} */ + let features; if (Array.isArray(options.features)) { features = /** @type {Array>} */ ( options.features ); } else if (options.features) { - collection = - /** @type {Collection>} */ ( - options.features - ); + collection = options.features; features = collection.getArray(); } if (!useSpatialIndex && collection === undefined) {