From 20125ae96cfc77bdb904bec0bc2ca748d304d6de Mon Sep 17 00:00:00 2001 From: William Wall Date: Wed, 19 Sep 2018 11:04:35 -0600 Subject: [PATCH] Type check fixes for VectorSource Added parameter types to event listeners. Fixed return type for feature collection branch. Removed duplicate template definition. --- src/ol/source/Vector.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index 97a8a168d3..cdbf8ce6bb 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -420,6 +420,9 @@ class VectorSource extends Source { bindFeaturesCollection_(collection) { let modifyingCollection = false; listen(this, VectorEventType.ADDFEATURE, + /** + * @param {VectorSourceEvent} evt The vector source event + */ function(evt) { if (!modifyingCollection) { modifyingCollection = true; @@ -428,6 +431,9 @@ class VectorSource extends Source { } }); listen(this, VectorEventType.REMOVEFEATURE, + /** + * @param {VectorSourceEvent} evt The vector source event + */ function(evt) { if (!modifyingCollection) { modifyingCollection = true; @@ -436,6 +442,9 @@ class VectorSource extends Source { } }); listen(collection, CollectionEventType.ADD, + /** + * @param {import("../Collection.js").CollectionEvent} evt The collection event + */ function(evt) { if (!modifyingCollection) { modifyingCollection = true; @@ -444,6 +453,9 @@ class VectorSource extends Source { } }, this); listen(collection, CollectionEventType.REMOVE, + /** + * @param {import("../Collection.js").CollectionEvent} evt The collection event + */ function(evt) { if (!modifyingCollection) { modifyingCollection = true; @@ -511,7 +523,7 @@ class VectorSource extends Source { if (this.featuresRtree_) { return this.featuresRtree_.forEach(callback); } else if (this.featuresCollection_) { - return this.featuresCollection_.forEach(callback); + this.featuresCollection_.forEach(callback); } } @@ -564,7 +576,7 @@ class VectorSource extends Source { if (this.featuresRtree_) { return this.featuresRtree_.forEachInExtent(extent, callback); } else if (this.featuresCollection_) { - return this.featuresCollection_.forEach(callback); + this.featuresCollection_.forEach(callback); } } @@ -589,7 +601,6 @@ class VectorSource extends Source { /** * @param {import("../Feature.js").default} feature Feature. * @return {T|undefined} The return value from the last call to the callback. - * @template T */ function(feature) { const geometry = feature.getGeometry();