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

View File

@@ -26,7 +26,7 @@ import RBush from '../structs/RBush.js';
* returns an array of {@link module:ol/extent~Extent} with the extents to load. Usually this
* is one of the standard {@link module:ol/loadingstrategy} strategies.
*
* @typedef {function(module:ol/extent~Extent, number): Array<module:ol/extent~Extent>} LoadingStrategy
* @typedef {function(import("../extent.js").Extent, number): Array<import("../extent.js").Extent>} LoadingStrategy
* @api
*/
@@ -40,7 +40,7 @@ export class VectorSourceEvent extends Event {
/**
* @param {string} type Type.
* @param {module:ol/Feature=} opt_feature Feature.
* @param {import("../Feature.js").default=} opt_feature Feature.
*/
constructor(type, opt_feature) {
@@ -48,7 +48,7 @@ export class VectorSourceEvent extends Event {
/**
* The feature being added or removed.
* @type {module:ol/Feature|undefined}
* @type {import("../Feature.js").default|undefined}
* @api
*/
this.feature = opt_feature;
@@ -60,13 +60,13 @@ export class VectorSourceEvent extends Event {
/**
* @typedef {Object} Options
* @property {module:ol/source/Source~AttributionLike} [attributions] Attributions.
* @property {Array<module:ol/Feature>|module:ol/Collection<module:ol/Feature>} [features]
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {Array<import("../Feature.js").default>|import("../Collection.js").default<import("../Feature.js").default>} [features]
* Features. If provided as {@link module:ol/Collection}, the features in the source
* and the collection will stay in sync.
* @property {module:ol/format/Feature} [format] The feature format used by the XHR
* @property {import("../format/Feature.js").default} [format] The feature format used by the XHR
* feature loader when `url` is set. Required if `url` is set, otherwise ignored.
* @property {module:ol/featureloader~FeatureLoader} [loader]
* @property {import("../featureloader.js").FeatureLoader} [loader]
* The loader function used to load features, from a remote source for example.
* If this is not set and `url` is set, the source will create and use an XHR
* feature loader.
@@ -109,10 +109,10 @@ export class VectorSourceEvent extends Event {
* Setting this to `false` (e.g. for sources with polygons that represent administrative
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
* stroke operations.
* @property {module:ol/source/Vector~LoadingStrategy} [strategy] The loading strategy to use.
* @property {LoadingStrategy} [strategy] The loading strategy to use.
* By default an {@link module:ol/loadingstrategy~all}
* strategy is used, a one-off strategy which loads all features at once.
* @property {string|module:ol/featureloader~FeatureUrlFunction} [url]
* @property {string|import("../featureloader.js").FeatureUrlFunction} [url]
* Setting this option instructs the source to load features using an XHR loader
* (see {@link module:ol/featureloader~xhr}). Use a `string` and an
* {@link module:ol/loadingstrategy~all} for a one-off download of all features from
@@ -159,7 +159,7 @@ export class VectorSourceEvent extends Event {
*/
class VectorSource extends Source {
/**
* @param {module:ol/source/Vector~Options=} opt_options Vector source options.
* @param {Options=} opt_options Vector source options.
*/
constructor(opt_options) {
@@ -174,13 +174,13 @@ class VectorSource extends Source {
/**
* @private
* @type {module:ol/featureloader~FeatureLoader}
* @type {import("../featureloader.js").FeatureLoader}
*/
this.loader_ = VOID;
/**
* @private
* @type {module:ol/format/Feature|undefined}
* @type {import("../format/Feature.js").default|undefined}
*/
this.format_ = options.format;
@@ -192,7 +192,7 @@ class VectorSource extends Source {
/**
* @private
* @type {string|module:ol/featureloader~FeatureUrlFunction|undefined}
* @type {string|import("../featureloader.js").FeatureUrlFunction|undefined}
*/
this.url_ = options.url;
@@ -201,12 +201,12 @@ class VectorSource extends Source {
} else if (this.url_ !== undefined) {
assert(this.format_, 7); // `format` must be set when `url` is set
// create a XHR feature loader for "url" and "format"
this.loader_ = xhr(this.url_, /** @type {module:ol/format/Feature} */ (this.format_));
this.loader_ = xhr(this.url_, /** @type {import("../format/Feature.js").default} */ (this.format_));
}
/**
* @private
* @type {module:ol/source/Vector~LoadingStrategy}
* @type {LoadingStrategy}
*/
this.strategy_ = options.strategy !== undefined ? options.strategy : allStrategy;
@@ -215,45 +215,45 @@ class VectorSource extends Source {
/**
* @private
* @type {module:ol/structs/RBush<module:ol/Feature>}
* @type {import("../structs/RBush.js").default<import("../Feature.js").default>}
*/
this.featuresRtree_ = useSpatialIndex ? new RBush() : null;
/**
* @private
* @type {module:ol/structs/RBush<{extent: module:ol/extent~Extent}>}
* @type {import("../structs/RBush.js").default<{extent: import("../extent.js").Extent}>}
*/
this.loadedExtentsRtree_ = new RBush();
/**
* @private
* @type {!Object<string, module:ol/Feature>}
* @type {!Object<string, import("../Feature.js").default>}
*/
this.nullGeometryFeatures_ = {};
/**
* A lookup of features by id (the return from feature.getId()).
* @private
* @type {!Object<string, module:ol/Feature>}
* @type {!Object<string, import("../Feature.js").default>}
*/
this.idIndex_ = {};
/**
* A lookup of features without id (keyed by getUid(feature)).
* @private
* @type {!Object<string, module:ol/Feature>}
* @type {!Object<string, import("../Feature.js").default>}
*/
this.undefIdIndex_ = {};
/**
* @private
* @type {Object<string, Array<module:ol/events~EventsKey>>}
* @type {Object<string, Array<import("../events.js").EventsKey>>}
*/
this.featureChangeKeys_ = {};
/**
* @private
* @type {module:ol/Collection<module:ol/Feature>}
* @type {import("../Collection.js").default<import("../Feature.js").default>}
*/
this.featuresCollection_ = null;
@@ -282,7 +282,7 @@ class VectorSource extends Source {
* instead. A feature will not be added to the source if feature with
* the same id is already there. The reason for this behavior is to avoid
* feature duplication when using bbox or tile loading strategies.
* @param {module:ol/Feature} feature Feature to add.
* @param {import("../Feature.js").default} feature Feature to add.
* @api
*/
addFeature(feature) {
@@ -293,7 +293,7 @@ class VectorSource extends Source {
/**
* Add a feature without firing a `change` event.
* @param {module:ol/Feature} feature Feature.
* @param {import("../Feature.js").default} feature Feature.
* @protected
*/
addFeatureInternal(feature) {
@@ -322,7 +322,7 @@ class VectorSource extends Source {
/**
* @param {string} featureKey Unique identifier for the feature.
* @param {module:ol/Feature} feature The feature.
* @param {import("../Feature.js").default} feature The feature.
* @private
*/
setupChangeEvents_(featureKey, feature) {
@@ -337,7 +337,7 @@ class VectorSource extends Source {
/**
* @param {string} featureKey Unique identifier for the feature.
* @param {module:ol/Feature} feature The feature.
* @param {import("../Feature.js").default} feature The feature.
* @return {boolean} The feature is "valid", in the sense that it is also a
* candidate for insertion into the Rtree.
* @private
@@ -362,7 +362,7 @@ class VectorSource extends Source {
/**
* Add a batch of features to the source.
* @param {Array<module:ol/Feature>} features Features to add.
* @param {Array<import("../Feature.js").default>} features Features to add.
* @api
*/
addFeatures(features) {
@@ -373,7 +373,7 @@ class VectorSource extends Source {
/**
* Add features without firing a `change` event.
* @param {Array<module:ol/Feature>} features Features.
* @param {Array<import("../Feature.js").default>} features Features.
* @protected
*/
addFeaturesInternal(features) {
@@ -414,7 +414,7 @@ class VectorSource extends Source {
/**
* @param {!module:ol/Collection<module:ol/Feature>} collection Collection.
* @param {!import("../Collection.js").default<import("../Feature.js").default>} collection Collection.
* @private
*/
bindFeaturesCollection_(collection) {
@@ -439,7 +439,7 @@ class VectorSource extends Source {
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
this.addFeature(/** @type {module:ol/Feature} */ (evt.element));
this.addFeature(/** @type {import("../Feature.js").default} */ (evt.element));
modifyingCollection = false;
}
}, this);
@@ -447,7 +447,7 @@ class VectorSource extends Source {
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
this.removeFeature(/** @type {module:ol/Feature} */ (evt.element));
this.removeFeature(/** @type {import("../Feature.js").default} */ (evt.element));
modifyingCollection = false;
}
}, this);
@@ -501,7 +501,7 @@ class VectorSource extends Source {
* stop and the function will return the same value.
* Note: this function only iterate through the feature that have a defined geometry.
*
* @param {function(module:ol/Feature): T} callback Called with each feature
* @param {function(import("../Feature.js").default): T} callback Called with each feature
* on the source. Return a truthy value to stop iteration.
* @return {T|undefined} The return value from the last call to the callback.
* @template T
@@ -522,8 +522,8 @@ class VectorSource extends Source {
* a "truthy" value, iteration will stop and the function will return the same
* value.
*
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
* @param {function(module:ol/Feature): T} callback Called with each feature
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {function(import("../Feature.js").default): T} callback Called with each feature
* whose goemetry contains the provided coordinate.
* @return {T|undefined} The return value from the last call to the callback.
* @template T
@@ -553,8 +553,8 @@ class VectorSource extends Source {
* When `useSpatialIndex` is set to false, this method will loop through all
* features, equivalent to {@link module:ol/source/Vector~VectorSource#forEachFeature #forEachFeature()}.
*
* @param {module:ol/extent~Extent} extent Extent.
* @param {function(module:ol/Feature): T} callback Called with each feature
* @param {import("../extent.js").Extent} extent Extent.
* @param {function(import("../Feature.js").default): T} callback Called with each feature
* whose bounding box intersects the provided extent.
* @return {T|undefined} The return value from the last call to the callback.
* @template T
@@ -577,8 +577,8 @@ class VectorSource extends Source {
* If you only want to test for bounding box intersection, call the
* {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent #forEachFeatureInExtent()} method instead.
*
* @param {module:ol/extent~Extent} extent Extent.
* @param {function(module:ol/Feature): T} callback Called with each feature
* @param {import("../extent.js").Extent} extent Extent.
* @param {function(import("../Feature.js").default): T} callback Called with each feature
* whose geometry intersects the provided extent.
* @return {T|undefined} The return value from the last call to the callback.
* @template T
@@ -587,7 +587,7 @@ class VectorSource extends Source {
forEachFeatureIntersectingExtent(extent, callback) {
return this.forEachFeatureInExtent(extent,
/**
* @param {module:ol/Feature} feature Feature.
* @param {import("../Feature.js").default} feature Feature.
* @return {T|undefined} The return value from the last call to the callback.
* @template T
*/
@@ -607,7 +607,7 @@ class VectorSource extends Source {
* Get the features collection associated with this source. Will be `null`
* unless the source was configured with `useSpatialIndex` set to `false`, or
* with an {@link module:ol/Collection} as `features`.
* @return {module:ol/Collection<module:ol/Feature>} The collection of features.
* @return {import("../Collection.js").default<import("../Feature.js").default>} The collection of features.
* @api
*/
getFeaturesCollection() {
@@ -617,7 +617,7 @@ class VectorSource extends Source {
/**
* Get all features on the source in random order.
* @return {Array<module:ol/Feature>} Features.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
getFeatures() {
@@ -631,15 +631,15 @@ class VectorSource extends Source {
}
}
return (
/** @type {Array<module:ol/Feature>} */ (features)
/** @type {Array<import("../Feature.js").default>} */ (features)
);
}
/**
* Get all features whose geometry intersects the provided coordinate.
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
* @return {Array<module:ol/Feature>} Features.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
getFeaturesAtCoordinate(coordinate) {
@@ -658,8 +658,8 @@ class VectorSource extends Source {
*
* This method is not available when the source is configured with
* `useSpatialIndex` set to `false`.
* @param {module:ol/extent~Extent} extent Extent.
* @return {Array<module:ol/Feature>} Features.
* @param {import("../extent.js").Extent} extent Extent.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
getFeaturesInExtent(extent) {
@@ -672,11 +672,11 @@ class VectorSource extends Source {
*
* This method is not available when the source is configured with
* `useSpatialIndex` set to `false`.
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
* @param {function(module:ol/Feature):boolean=} opt_filter Feature filter function.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {function(import("../Feature.js").default):boolean=} opt_filter Feature filter function.
* The filter function will receive one argument, the {@link module:ol/Feature feature}
* and it should return a boolean value. By default, no filtering is made.
* @return {module:ol/Feature} Closest feature.
* @return {import("../Feature.js").default} Closest feature.
* @api
*/
getClosestFeatureToCoordinate(coordinate, opt_filter) {
@@ -696,7 +696,7 @@ class VectorSource extends Source {
const filter = opt_filter ? opt_filter : TRUE;
this.featuresRtree_.forEachInExtent(extent,
/**
* @param {module:ol/Feature} feature Feature.
* @param {import("../Feature.js").default} feature Feature.
*/
function(feature) {
if (filter(feature)) {
@@ -727,9 +727,9 @@ class VectorSource extends Source {
*
* This method is not available when the source is configured with
* `useSpatialIndex` set to `false`.
* @param {module:ol/extent~Extent=} opt_extent Destination extent. If provided, no new extent
* @param {import("../extent.js").Extent=} opt_extent Destination extent. If provided, no new extent
* will be created. Instead, that extent's coordinates will be overwritten.
* @return {module:ol/extent~Extent} Extent.
* @return {import("../extent.js").Extent} Extent.
* @api
*/
getExtent(opt_extent) {
@@ -743,7 +743,7 @@ class VectorSource extends Source {
* `source.getFeatureById(2)` will return a feature with id `'2'` or `2`.
*
* @param {string|number} id Feature identifier.
* @return {module:ol/Feature} The feature (or `null` if not found).
* @return {import("../Feature.js").default} The feature (or `null` if not found).
* @api
*/
getFeatureById(id) {
@@ -755,7 +755,7 @@ class VectorSource extends Source {
/**
* Get the format associated with this source.
*
* @return {module:ol/format/Feature|undefined} The feature format.
* @return {import("../format/Feature.js").default|undefined} The feature format.
* @api
*/
getFormat() {
@@ -780,7 +780,7 @@ class VectorSource extends Source {
/**
* Get the url associated with this source.
*
* @return {string|module:ol/featureloader~FeatureUrlFunction|undefined} The url.
* @return {string|import("../featureloader.js").FeatureUrlFunction|undefined} The url.
* @api
*/
getUrl() {
@@ -789,11 +789,11 @@ class VectorSource extends Source {
/**
* @param {module:ol/events/Event} event Event.
* @param {import("../events/Event.js").default} event Event.
* @private
*/
handleFeatureChange_(event) {
const feature = /** @type {module:ol/Feature} */ (event.target);
const feature = /** @type {import("../Feature.js").default} */ (event.target);
const featureKey = getUid(feature).toString();
const geometry = feature.getGeometry();
if (!geometry) {
@@ -841,7 +841,7 @@ class VectorSource extends Source {
/**
* Returns true if the feature is contained within the source.
* @param {module:ol/Feature} feature Feature.
* @param {import("../Feature.js").default} feature Feature.
* @return {boolean} Has feature.
* @api
*/
@@ -864,9 +864,9 @@ class VectorSource extends Source {
/**
* @param {module:ol/extent~Extent} extent Extent.
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {module:ol/proj/Projection} projection Projection.
* @param {import("../proj/Projection.js").default} projection Projection.
*/
loadFeatures(extent, resolution, projection) {
const loadedExtentsRtree = this.loadedExtentsRtree_;
@@ -876,7 +876,7 @@ class VectorSource extends Source {
const extentToLoad = extentsToLoad[i];
const alreadyLoaded = loadedExtentsRtree.forEachInExtent(extentToLoad,
/**
* @param {{extent: module:ol/extent~Extent}} object Object.
* @param {{extent: import("../extent.js").Extent}} object Object.
* @return {boolean} Contains.
*/
function(object) {
@@ -893,7 +893,7 @@ class VectorSource extends Source {
/**
* Remove an extent from the list of loaded extents.
* @param {module:ol/extent~Extent} extent Extent.
* @param {import("../extent.js").Extent} extent Extent.
* @api
*/
removeLoadedExtent(extent) {
@@ -915,7 +915,7 @@ class VectorSource extends Source {
* Remove a single feature from the source. If you want to remove all features
* at once, use the {@link module:ol/source/Vector~VectorSource#clear #clear()} method
* instead.
* @param {module:ol/Feature} feature Feature to remove.
* @param {import("../Feature.js").default} feature Feature to remove.
* @api
*/
removeFeature(feature) {
@@ -934,7 +934,7 @@ class VectorSource extends Source {
/**
* Remove feature without firing a `change` event.
* @param {module:ol/Feature} feature Feature.
* @param {import("../Feature.js").default} feature Feature.
* @protected
*/
removeFeatureInternal(feature) {
@@ -955,7 +955,7 @@ class VectorSource extends Source {
/**
* Remove a feature from the id index. Called internally when the feature id
* may have changed.
* @param {module:ol/Feature} feature The feature.
* @param {import("../Feature.js").default} feature The feature.
* @return {boolean} Removed the feature from the index.
* @private
*/
@@ -975,7 +975,7 @@ class VectorSource extends Source {
/**
* Set the new loader of the source. The next loadFeatures call will use the
* new loader.
* @param {module:ol/featureloader~FeatureLoader} loader The loader to set.
* @param {import("../featureloader.js").FeatureLoader} loader The loader to set.
* @api
*/
setLoader(loader) {