Type check fixes for VectorSource

Added parameter types to event listeners. Fixed return type for
feature collection branch. Removed duplicate template definition.
This commit is contained in:
William Wall
2018-09-19 11:04:35 -06:00
parent 978b039ddc
commit 20125ae96c

View File

@@ -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();