Improve Collection type-safety

This commit is contained in:
Maximilian Krög
2022-07-30 02:32:54 +02:00
parent 6e4e49644d
commit 75c17e55b1
9 changed files with 77 additions and 77 deletions
+5 -16
View File
@@ -302,10 +302,7 @@ class VectorSource extends Source {
/** @type {Array<import("../Feature.js").default<Geometry>>} */
let features;
if (Array.isArray(options.features)) {
features =
/** @type {Array<import("../Feature.js").default<Geometry>>} */ (
options.features
);
features = options.features;
} else if (options.features) {
collection = options.features;
features = collection.getArray();
@@ -501,16 +498,12 @@ class VectorSource extends Source {
collection.addEventListener(
CollectionEventType.ADD,
/**
* @param {import("../Collection.js").CollectionEvent} evt The collection event
* @param {import("../Collection.js").CollectionEvent<import("../Feature.js").default<Geometry>>} evt The collection event
*/
function (evt) {
if (!modifyingCollection) {
modifyingCollection = true;
this.addFeature(
/** @type {import("../Feature.js").default<Geometry>} */ (
evt.element
)
);
this.addFeature(evt.element);
modifyingCollection = false;
}
}.bind(this)
@@ -518,16 +511,12 @@ class VectorSource extends Source {
collection.addEventListener(
CollectionEventType.REMOVE,
/**
* @param {import("../Collection.js").CollectionEvent} evt The collection event
* @param {import("../Collection.js").CollectionEvent<import("../Feature.js").default<Geometry>>} evt The collection event
*/
function (evt) {
if (!modifyingCollection) {
modifyingCollection = true;
this.removeFeature(
/** @type {import("../Feature.js").default<Geometry>} */ (
evt.element
)
);
this.removeFeature(evt.element);
modifyingCollection = false;
}
}.bind(this)