Transformed types

Using the [ts.js codemod](https://gist.github.com/tschaub/1ea498c9d1e5268cf36d212b3949be4e):

    jscodeshift --transform ts.js src
This commit is contained in:
Tim Schaub
2018-09-05 08:05:29 -06:00
parent f2aaaa19e1
commit ccfacc5ee6
239 changed files with 3999 additions and 3999 deletions
+66 -66
View File
@@ -21,26 +21,26 @@ import RBush from '../structs/RBush.js';
/**
* @typedef {Object} Result
* @property {boolean} snapped
* @property {module:ol/coordinate~Coordinate|null} vertex
* @property {module:ol/pixel~Pixel|null} vertexPixel
* @property {import("../coordinate.js").Coordinate|null} vertex
* @property {import("../pixel.js").Pixel|null} vertexPixel
*/
/**
* @typedef {Object} SegmentData
* @property {module:ol/Feature} feature
* @property {Array<module:ol/coordinate~Coordinate>} segment
* @property {import("../Feature.js").default} feature
* @property {Array<import("../coordinate.js").Coordinate>} segment
*/
/**
* @typedef {Object} Options
* @property {module:ol/Collection<module:ol/Feature>} [features] Snap to these features. Either this option or source should be provided.
* @property {import("../Collection.js").default<import("../Feature.js").default>} [features] Snap to these features. Either this option or source should be provided.
* @property {boolean} [edge=true] Snap to edges.
* @property {boolean} [vertex=true] Snap to vertices.
* @property {number} [pixelTolerance=10] Pixel tolerance for considering the pointer close enough to a segment or
* vertex for snapping.
* @property {module:ol/source/Vector} [source] Snap to features from this source. Either this option or features should be provided
* @property {import("../source/Vector.js").default} [source] Snap to features from this source. Either this option or features should be provided
*/
@@ -67,7 +67,7 @@ import RBush from '../structs/RBush.js';
*/
class Snap extends PointerInteraction {
/**
* @param {module:ol/interaction/Snap~Options=} opt_options Options.
* @param {Options=} opt_options Options.
*/
constructor(opt_options) {
@@ -81,7 +81,7 @@ class Snap extends PointerInteraction {
const options = opt_options ? opt_options : {};
/**
* @type {module:ol/source/Vector}
* @type {import("../source/Vector.js").default}
* @private
*/
this.source_ = options.source ? options.source : null;
@@ -99,19 +99,19 @@ class Snap extends PointerInteraction {
this.edge_ = options.edge !== undefined ? options.edge : true;
/**
* @type {module:ol/Collection<module:ol/Feature>}
* @type {import("../Collection.js").default<import("../Feature.js").default>}
* @private
*/
this.features_ = options.features ? options.features : null;
/**
* @type {Array<module:ol/events~EventsKey>}
* @type {Array<import("../events.js").EventsKey>}
* @private
*/
this.featuresListenerKeys_ = [];
/**
* @type {Object<number, module:ol/events~EventsKey>}
* @type {Object<number, import("../events.js").EventsKey>}
* @private
*/
this.featureChangeListenerKeys_ = {};
@@ -119,7 +119,7 @@ class Snap extends PointerInteraction {
/**
* Extents are preserved so indexed segment can be quickly removed
* when its feature geometry changes
* @type {Object<number, module:ol/extent~Extent>}
* @type {Object<number, import("../extent.js").Extent>}
* @private
*/
this.indexedFeaturesExtents_ = {};
@@ -128,14 +128,14 @@ class Snap extends PointerInteraction {
* If a feature geometry changes while a pointer drag|move event occurs, the
* feature doesn't get updated right away. It will be at the next 'pointerup'
* event fired.
* @type {!Object<number, module:ol/Feature>}
* @type {!Object<number, import("../Feature.js").default>}
* @private
*/
this.pendingFeatures_ = {};
/**
* Used for distance sorting in sortByDistance_
* @type {module:ol/coordinate~Coordinate}
* @type {import("../coordinate.js").Coordinate}
* @private
*/
this.pixelCoordinate_ = null;
@@ -148,7 +148,7 @@ class Snap extends PointerInteraction {
options.pixelTolerance : 10;
/**
* @type {function(module:ol/interaction/Snap~SegmentData, module:ol/interaction/Snap~SegmentData): number}
* @type {function(SegmentData, SegmentData): number}
* @private
*/
this.sortByDistance_ = sortByDistance.bind(this);
@@ -156,7 +156,7 @@ class Snap extends PointerInteraction {
/**
* Segment RTree for each layer
* @type {module:ol/structs/RBush<module:ol/interaction/Snap~SegmentData>}
* @type {import("../structs/RBush.js").default<SegmentData>}
* @private
*/
this.rBush_ = new RBush();
@@ -165,7 +165,7 @@ class Snap extends PointerInteraction {
/**
* @const
* @private
* @type {Object<string, function(module:ol/Feature, module:ol/geom/Geometry)>}
* @type {Object<string, function(import("../Feature.js").default, import("../geom/Geometry.js").default)>}
*/
this.SEGMENT_WRITERS_ = {
'Point': this.writePointGeometry_,
@@ -182,7 +182,7 @@ class Snap extends PointerInteraction {
/**
* Add a feature to the collection of features that we may snap to.
* @param {module:ol/Feature} feature Feature.
* @param {import("../Feature.js").default} feature Feature.
* @param {boolean=} opt_listen Whether to listen to the feature change or not
* Defaults to `true`.
* @api
@@ -208,7 +208,7 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature.
* @param {import("../Feature.js").default} feature Feature.
* @private
*/
forEachFeatureAdd_(feature) {
@@ -216,7 +216,7 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature.
* @param {import("../Feature.js").default} feature Feature.
* @private
*/
forEachFeatureRemove_(feature) {
@@ -224,7 +224,7 @@ class Snap extends PointerInteraction {
}
/**
* @return {module:ol/Collection<module:ol/Feature>|Array<module:ol/Feature>} Features.
* @return {import("../Collection.js").default<import("../Feature.js").default>|Array<import("../Feature.js").default>} Features.
* @private
*/
getFeatures_() {
@@ -235,12 +235,12 @@ class Snap extends PointerInteraction {
features = this.source_.getFeatures();
}
return (
/** @type {!Array<module:ol/Feature>|!module:ol/Collection<module:ol/Feature>} */ (features)
/** @type {!Array<import("../Feature.js").default>|!import("../Collection.js").default<import("../Feature.js").default>} */ (features)
);
}
/**
* @param {module:ol/source/Vector|module:ol/Collection~CollectionEvent} evt Event.
* @param {import("../source/Vector.js").default|import("../Collection.js").CollectionEvent} evt Event.
* @private
*/
handleFeatureAdd_(evt) {
@@ -250,11 +250,11 @@ class Snap extends PointerInteraction {
} else if (evt instanceof CollectionEvent) {
feature = evt.element;
}
this.addFeature(/** @type {module:ol/Feature} */ (feature));
this.addFeature(/** @type {import("../Feature.js").default} */ (feature));
}
/**
* @param {module:ol/source/Vector|module:ol/Collection~CollectionEvent} evt Event.
* @param {import("../source/Vector.js").default|import("../Collection.js").CollectionEvent} evt Event.
* @private
*/
handleFeatureRemove_(evt) {
@@ -264,15 +264,15 @@ class Snap extends PointerInteraction {
} else if (evt instanceof CollectionEvent) {
feature = evt.element;
}
this.removeFeature(/** @type {module:ol/Feature} */ (feature));
this.removeFeature(/** @type {import("../Feature.js").default} */ (feature));
}
/**
* @param {module:ol/events/Event} evt Event.
* @param {import("../events/Event.js").default} evt Event.
* @private
*/
handleFeatureChange_(evt) {
const feature = /** @type {module:ol/Feature} */ (evt.target);
const feature = /** @type {import("../Feature.js").default} */ (evt.target);
if (this.handlingDownUpSequence) {
const uid = getUid(feature);
if (!(uid in this.pendingFeatures_)) {
@@ -285,7 +285,7 @@ class Snap extends PointerInteraction {
/**
* Remove a feature from the collection of features that we may snap to.
* @param {module:ol/Feature} feature Feature
* @param {import("../Feature.js").default} feature Feature
* @param {boolean=} opt_unlisten Whether to unlisten to the feature change
* or not. Defaults to `true`.
* @api
@@ -349,10 +349,10 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/pixel~Pixel} pixel Pixel
* @param {module:ol/coordinate~Coordinate} pixelCoordinate Coordinate
* @param {module:ol/PluggableMap} map Map.
* @return {module:ol/interaction/Snap~Result} Snap result
* @param {import("../pixel.js").Pixel} pixel Pixel
* @param {import("../coordinate.js").Coordinate} pixelCoordinate Coordinate
* @param {import("../PluggableMap.js").default} map Map.
* @return {Result} Snap result
*/
snapTo(pixel, pixelCoordinate, map) {
@@ -398,7 +398,7 @@ class Snap extends PointerInteraction {
} else if (this.edge_) {
if (isCircle) {
vertex = closestOnCircle(pixelCoordinate,
/** @type {module:ol/geom/Circle} */ (segments[0].feature.getGeometry()));
/** @type {import("../geom/Circle.js").default} */ (segments[0].feature.getGeometry()));
} else {
vertex = closestOnSegment(pixelCoordinate, closestSegment);
}
@@ -424,7 +424,7 @@ class Snap extends PointerInteraction {
}
}
return (
/** @type {module:ol/interaction/Snap~Result} */ ({
/** @type {Result} */ ({
snapped: snapped,
vertex: vertex,
vertexPixel: vertexPixel
@@ -433,7 +433,7 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature
* @param {import("../Feature.js").default} feature Feature
* @private
*/
updateFeature_(feature) {
@@ -442,8 +442,8 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature
* @param {module:ol/geom/Circle} geometry Geometry.
* @param {import("../Feature.js").default} feature Feature
* @param {import("../geom/Circle.js").default} geometry Geometry.
* @private
*/
writeCircleGeometry_(feature, geometry) {
@@ -451,7 +451,7 @@ class Snap extends PointerInteraction {
const coordinates = polygon.getCoordinates()[0];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
const segmentData = /** @type {SegmentData} */ ({
feature: feature,
segment: segment
});
@@ -460,8 +460,8 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature
* @param {module:ol/geom/GeometryCollection} geometry Geometry.
* @param {import("../Feature.js").default} feature Feature
* @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
* @private
*/
writeGeometryCollectionGeometry_(feature, geometry) {
@@ -475,15 +475,15 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature
* @param {module:ol/geom/LineString} geometry Geometry.
* @param {import("../Feature.js").default} feature Feature
* @param {import("../geom/LineString.js").default} geometry Geometry.
* @private
*/
writeLineStringGeometry_(feature, geometry) {
const coordinates = geometry.getCoordinates();
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
const segmentData = /** @type {SegmentData} */ ({
feature: feature,
segment: segment
});
@@ -492,8 +492,8 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature
* @param {module:ol/geom/MultiLineString} geometry Geometry.
* @param {import("../Feature.js").default} feature Feature
* @param {import("../geom/MultiLineString.js").default} geometry Geometry.
* @private
*/
writeMultiLineStringGeometry_(feature, geometry) {
@@ -502,7 +502,7 @@ class Snap extends PointerInteraction {
const coordinates = lines[j];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
const segmentData = /** @type {SegmentData} */ ({
feature: feature,
segment: segment
});
@@ -512,15 +512,15 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature
* @param {module:ol/geom/MultiPoint} geometry Geometry.
* @param {import("../Feature.js").default} feature Feature
* @param {import("../geom/MultiPoint.js").default} geometry Geometry.
* @private
*/
writeMultiPointGeometry_(feature, geometry) {
const points = geometry.getCoordinates();
for (let i = 0, ii = points.length; i < ii; ++i) {
const coordinates = points[i];
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
const segmentData = /** @type {SegmentData} */ ({
feature: feature,
segment: [coordinates, coordinates]
});
@@ -529,8 +529,8 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature
* @param {module:ol/geom/MultiPolygon} geometry Geometry.
* @param {import("../Feature.js").default} feature Feature
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
* @private
*/
writeMultiPolygonGeometry_(feature, geometry) {
@@ -541,7 +541,7 @@ class Snap extends PointerInteraction {
const coordinates = rings[j];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
const segmentData = /** @type {SegmentData} */ ({
feature: feature,
segment: segment
});
@@ -552,13 +552,13 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature
* @param {module:ol/geom/Point} geometry Geometry.
* @param {import("../Feature.js").default} feature Feature
* @param {import("../geom/Point.js").default} geometry Geometry.
* @private
*/
writePointGeometry_(feature, geometry) {
const coordinates = geometry.getCoordinates();
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
const segmentData = /** @type {SegmentData} */ ({
feature: feature,
segment: [coordinates, coordinates]
});
@@ -566,8 +566,8 @@ class Snap extends PointerInteraction {
}
/**
* @param {module:ol/Feature} feature Feature
* @param {module:ol/geom/Polygon} geometry Geometry.
* @param {import("../Feature.js").default} feature Feature
* @param {import("../geom/Polygon.js").default} geometry Geometry.
* @private
*/
writePolygonGeometry_(feature, geometry) {
@@ -576,7 +576,7 @@ class Snap extends PointerInteraction {
const coordinates = rings[j];
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
const segment = coordinates.slice(i, i + 2);
const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({
const segmentData = /** @type {SegmentData} */ ({
feature: feature,
segment: segment
});
@@ -589,9 +589,9 @@ class Snap extends PointerInteraction {
/**
* Handle all pointer events events.
* @param {module:ol/MapBrowserEvent} evt A move event.
* @param {import("../MapBrowserEvent.js").default} evt A move event.
* @return {boolean} Pass the event to other interactions.
* @this {module:ol/interaction/Snap}
* @this {import("./Snap.js").default}
*/
export function handleEvent(evt) {
const result = this.snapTo(evt.pixel, evt.coordinate, evt.map);
@@ -604,9 +604,9 @@ export function handleEvent(evt) {
/**
* @param {module:ol/MapBrowserPointerEvent} evt Event.
* @param {import("../MapBrowserPointerEvent.js").default} evt Event.
* @return {boolean} Stop drag sequence?
* @this {module:ol/interaction/Snap}
* @this {import("./Snap.js").default}
*/
function handleUpEvent(evt) {
const featuresToUpdate = getValues(this.pendingFeatures_);
@@ -620,10 +620,10 @@ function handleUpEvent(evt) {
/**
* Sort segments by distance, helper function
* @param {module:ol/interaction/Snap~SegmentData} a The first segment data.
* @param {module:ol/interaction/Snap~SegmentData} b The second segment data.
* @param {SegmentData} a The first segment data.
* @param {SegmentData} b The second segment data.
* @return {number} The difference in distance.
* @this {module:ol/interaction/Snap}
* @this {import("./Snap.js").default}
*/
function sortByDistance(a, b) {
const deltaA = squaredDistanceToSegment(this.pixelCoordinate_, a.segment);