From 25c17540525c0ec1ad703a55d23c0da6115e07a0 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 3 Sep 2018 08:42:00 +0200 Subject: [PATCH 1/4] Cast empty optional options in constructor To remove the typescript errors: ``` Property 'xxx' does not exist on type '{}' ``` --- src/ol/PluggableMap.js | 2 +- src/ol/source/ImageArcGISRest.js | 2 +- src/ol/source/ImageWMS.js | 2 +- src/ol/source/TileWMS.js | 2 +- src/ol/style/Circle.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 5417cefc17..144c6e0aaf 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -615,7 +615,7 @@ class PluggableMap extends BaseObject { if (!this.frameState_) { return; } - const options = opt_options || {}; + const options = opt_options || /** @type {module:ol/PluggableMap~AtPixelOptions} */ ({}); const hitTolerance = options.hitTolerance !== undefined ? opt_options.hitTolerance * this.frameState_.pixelRatio : 0; const layerFilter = options.layerFilter || TRUE; diff --git a/src/ol/source/ImageArcGISRest.js b/src/ol/source/ImageArcGISRest.js index 5cce76bcd6..bbf3bfb24b 100644 --- a/src/ol/source/ImageArcGISRest.js +++ b/src/ol/source/ImageArcGISRest.js @@ -57,7 +57,7 @@ class ImageArcGISRest extends ImageSource { */ constructor(opt_options) { - const options = opt_options || {}; + const options = opt_options || /** @type {module:ol/source/ImageArcGISRest~Options} */ ({}); super({ attributions: options.attributions, diff --git a/src/ol/source/ImageWMS.js b/src/ol/source/ImageWMS.js index 544348afbb..119d39d073 100644 --- a/src/ol/source/ImageWMS.js +++ b/src/ol/source/ImageWMS.js @@ -64,7 +64,7 @@ class ImageWMS extends ImageSource { */ constructor(opt_options) { - const options = opt_options || {}; + const options = opt_options || /** @type {module:ol/source/ImageWMS~Options} */ ({}); super({ attributions: options.attributions, diff --git a/src/ol/source/TileWMS.js b/src/ol/source/TileWMS.js index e34cf6492d..e96cec9ee6 100644 --- a/src/ol/source/TileWMS.js +++ b/src/ol/source/TileWMS.js @@ -82,7 +82,7 @@ class TileWMS extends TileImage { */ constructor(opt_options) { - const options = opt_options || {}; + const options = opt_options || /** @type {module:ol/source/TileWMS~Options} */ ({}); const params = options.params || {}; diff --git a/src/ol/style/Circle.js b/src/ol/style/Circle.js index 3dd4e703d1..974814c3a4 100644 --- a/src/ol/style/Circle.js +++ b/src/ol/style/Circle.js @@ -27,7 +27,7 @@ class CircleStyle extends RegularShape { */ constructor(opt_options) { - const options = opt_options || {}; + const options = opt_options || /** @type {module:ol/style/Circle~Options} */ ({}); super({ points: Infinity, From 5fdac622efc71187aa1cd7d7171391599798de0b Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 3 Sep 2018 08:55:08 +0200 Subject: [PATCH 2/4] Add missing 'extent' property in VectorTile constructor --- src/ol/source/VectorTile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index 72c022acc0..42132f9dcb 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -14,6 +14,7 @@ import {createXYZ, extentFromProjection, createForProjection} from '../tilegrid. * @typedef {Object} Options * @property {module:ol/source/Source~AttributionLike} [attributions] Attributions. * @property {number} [cacheSize=128] Cache size. + * @property {module:ol/extent~Extent} [extent] * @property {module:ol/format/Feature} [format] Feature format for tiles. Used and required by the default. * @property {boolean} [overlaps=true] This source may have overlapping geometries. Setting this * to `false` (e.g. for sources with polygons that represent administrative @@ -73,7 +74,7 @@ import {createXYZ, extentFromProjection, createForProjection} from '../tilegrid. */ class VectorTile extends UrlTile { /** - * @param {module:ol/source/VectorTile~Options=} options Vector tile options. + * @param {!module:ol/source/VectorTile~Options} options Vector tile options. */ constructor(options) { const projection = options.projection || 'EPSG:3857'; From 3c02bd15fb767f7bb4522c0d14e306e6bde5f5e5 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 3 Sep 2018 08:56:34 +0200 Subject: [PATCH 3/4] Add missing 'extent' property in TileImage constructor --- src/ol/source/TileImage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index 290ef0725b..d018968b23 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -18,6 +18,7 @@ import {getForProjection as getTileGridForProjection} from '../tilegrid.js'; * @typedef {Object} Options * @property {module:ol/source/Source~AttributionLike} [attributions] Attributions. * @property {number} [cacheSize=2048] Cache size. + * @property {module:ol/extent~Extent} [extent] * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that * you must provide a `crossOrigin` value if you are using the WebGL renderer or if you want to * access pixel data with the Canvas renderer. See @@ -63,7 +64,7 @@ import {getForProjection as getTileGridForProjection} from '../tilegrid.js'; */ class TileImage extends UrlTile { /** - * @param {module:ol/source/TileImage~Options=} options Image tile options. + * @param {!module:ol/source/TileImage~Options} options Image tile options. */ constructor(options) { From 5b8b4705683a67b4206a422e18680bc32b3d0e02 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 3 Sep 2018 09:13:26 +0200 Subject: [PATCH 4/4] Fix imports in jsdoc blocks --- src/ol/interaction.js | 3 +-- src/ol/source/Vector.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ol/interaction.js b/src/ol/interaction.js index fdcb80c881..d9a3dfbe3e 100644 --- a/src/ol/interaction.js +++ b/src/ol/interaction.js @@ -80,8 +80,7 @@ export {default as Translate} from './interaction/Translate.js'; * * {@link module:ol/interaction/MouseWheelZoom~MouseWheelZoom} * * {@link module:ol/interaction/DragZoom~DragZoom} * - * @param {module:ol/interaction/Interaction~DefaultsOptions=} opt_options - * Defaults options. + * @param {module:ol/interaction~DefaultsOptions=} opt_options Defaults options. * @return {module:ol/Collection} * A collection of interactions to be used with the {@link module:ol/Map~Map} * constructor's `interactions` option. diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index 1b813701ff..9a7cbd992c 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -112,11 +112,11 @@ export class VectorSourceEvent extends Event { * @property {module:ol/source/Vector~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|module:ol/featureloader~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 - * the given URL. Use a {@link module:ol/featureloader~FeatureUrlfunction} to generate the url with + * the given URL. Use a {@link module:ol/featureloader~FeatureUrlFunction} to generate the url with * other loading strategies. * Requires `format` to be set as well. * When default XHR feature loader is provided, the features will