Fix type check errors in ol/interaction/Snap

This commit is contained in:
Kevin Schmidt
2018-10-03 11:20:56 -06:00
parent 38aa620afa
commit 9d4821aafc
+8 -10
View File
@@ -239,9 +239,7 @@ class Snap extends PointerInteraction {
} else if (this.source_) { } else if (this.source_) {
features = this.source_.getFeatures(); features = this.source_.getFeatures();
} }
return ( return features;
/** @type {!Array<import("../Feature.js").default>|!import("../Collection.js").default<import("../Feature.js").default>} */ (features)
);
} }
/** /**
@@ -257,7 +255,7 @@ class Snap extends PointerInteraction {
} }
/** /**
* @param {import("../source/Vector.js").default|import("../Collection.js").CollectionEvent} evt Event. * @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent} evt Event.
* @private * @private
*/ */
handleFeatureAdd_(evt) { handleFeatureAdd_(evt) {
@@ -265,13 +263,13 @@ class Snap extends PointerInteraction {
if (evt instanceof VectorSourceEvent) { if (evt instanceof VectorSourceEvent) {
feature = evt.feature; feature = evt.feature;
} else if (evt instanceof CollectionEvent) { } else if (evt instanceof CollectionEvent) {
feature = evt.element; feature = /** @type {import("../Feature.js").default} */ (evt.element);
} }
this.addFeature(/** @type {import("../Feature.js").default} */ (feature)); this.addFeature(feature);
} }
/** /**
* @param {import("../source/Vector.js").default|import("../Collection.js").CollectionEvent} evt Event. * @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent} evt Event.
* @private * @private
*/ */
handleFeatureRemove_(evt) { handleFeatureRemove_(evt) {
@@ -279,9 +277,9 @@ class Snap extends PointerInteraction {
if (evt instanceof VectorSourceEvent) { if (evt instanceof VectorSourceEvent) {
feature = evt.feature; feature = evt.feature;
} else if (evt instanceof CollectionEvent) { } else if (evt instanceof CollectionEvent) {
feature = evt.element; feature = /** @type {import("../Feature.js").default} */ (evt.element);
} }
this.removeFeature(/** @type {import("../Feature.js").default} */ (feature)); this.removeFeature(feature);
} }
/** /**
@@ -348,7 +346,7 @@ class Snap extends PointerInteraction {
setMap(map) { setMap(map) {
const currentMap = this.getMap(); const currentMap = this.getMap();
const keys = this.featuresListenerKeys_; const keys = this.featuresListenerKeys_;
const features = this.getFeatures_(); const features = /** @type {Array<import("../Feature.js").default>} */ (this.getFeatures_());
if (currentMap) { if (currentMap) {
keys.forEach(unlistenByKey); keys.forEach(unlistenByKey);