From ea88e6cbd415dd75f01ae9fc27204f3c762bc1f7 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 27 Sep 2019 11:01:50 +0200 Subject: [PATCH 1/4] Remove invalid undefined type in params --- src/ol/Overlay.js | 4 ++-- src/ol/renderer/webgl/PointsLayer.js | 2 +- src/ol/webgl/PostProcessingPass.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ol/Overlay.js b/src/ol/Overlay.js index f8d71f695a..c74d9bdf3e 100644 --- a/src/ol/Overlay.js +++ b/src/ol/Overlay.js @@ -436,8 +436,8 @@ class Overlay extends BaseObject { /** * Get the extent of an element relative to the document - * @param {HTMLElement|undefined} element The element. - * @param {import("./size.js").Size|undefined} size The size of the element. + * @param {HTMLElement} element The element. + * @param {import("./size.js").Size} size The size of the element. * @return {import("./extent.js").Extent} The extent. * @protected */ diff --git a/src/ol/renderer/webgl/PointsLayer.js b/src/ol/renderer/webgl/PointsLayer.js index 226b729b0d..d9a5495cc9 100644 --- a/src/ol/renderer/webgl/PointsLayer.js +++ b/src/ol/renderer/webgl/PointsLayer.js @@ -109,7 +109,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer { /** * @param {import("../../layer/Layer.js").default} layer Layer. - * @param {Options=} options Options. + * @param {Options} options Options. */ constructor(layer, options) { const uniforms = options.uniforms || {}; diff --git a/src/ol/webgl/PostProcessingPass.js b/src/ol/webgl/PostProcessingPass.js index 1405398354..683e600c41 100644 --- a/src/ol/webgl/PostProcessingPass.js +++ b/src/ol/webgl/PostProcessingPass.js @@ -101,7 +101,7 @@ const DEFAULT_FRAGMENT_SHADER = ` class WebGLPostProcessingPass { /** - * @param {Options=} options Options. + * @param {Options} options Options. */ constructor(options) { this.gl_ = options.webGlContext; From 701dc3b54a10eb66b103c50efdd062bdfdf74656 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 27 Sep 2019 11:03:21 +0200 Subject: [PATCH 2/4] Use the right variable to get the hitTolerance value --- src/ol/PluggableMap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 415cf31317..a064ae88b2 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -604,7 +604,7 @@ class PluggableMap extends BaseObject { } const options = opt_options || /** @type {AtPixelOptions} */ ({}); const hitTolerance = options.hitTolerance !== undefined ? - opt_options.hitTolerance * this.frameState_.pixelRatio : 0; + options.hitTolerance * this.frameState_.pixelRatio : 0; const layerFilter = options.layerFilter || TRUE; return this.renderer_.forEachLayerAtPixel(pixel, this.frameState_, hitTolerance, callback, layerFilter); } From 0e402073dab5150bf2d0ac5e04c037c760bf9f1f Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 27 Sep 2019 13:09:12 +0200 Subject: [PATCH 3/4] Add more typecast for typescript --- src/ol/PluggableMap.js | 8 ++++---- src/ol/css.js | 3 +++ src/ol/render/canvas.js | 3 +++ src/ol/source/TileWMS.js | 2 +- src/ol/structs/LRUCache.js | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index a064ae88b2..a65da29671 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -375,9 +375,9 @@ class PluggableMap extends BaseObject { * @param {import("./control/Control.js").default} control Control. * @this {PluggableMap} */ - (function(control) { + function(control) { control.setMap(this); - }).bind(this)); + }.bind(this)); this.controls.addEventListener(CollectionEventType.ADD, /** @@ -400,9 +400,9 @@ class PluggableMap extends BaseObject { * @param {import("./interaction/Interaction.js").default} interaction Interaction. * @this {PluggableMap} */ - (function(interaction) { + function(interaction) { interaction.setMap(this); - }).bind(this)); + }.bind(this)); this.interactions.addEventListener(CollectionEventType.ADD, /** diff --git a/src/ol/css.js b/src/ol/css.js index 74455ec41a..c855fae7ea 100644 --- a/src/ol/css.js +++ b/src/ol/css.js @@ -72,6 +72,9 @@ export const CLASS_COLLAPSED = 'ol-collapsed'; * @return {FontParameters} The font families (or null if the input spec is invalid). */ export const getFontParameters = (function() { + /** + * @type {CSSStyleDeclaration} + */ let style; /** * @type {Object} diff --git a/src/ol/render/canvas.js b/src/ol/render/canvas.js index 2d995c624b..8d0bfc2913 100644 --- a/src/ol/render/canvas.js +++ b/src/ol/render/canvas.js @@ -300,6 +300,9 @@ function getMeasureContext() { * @return {import("../size.js").Size} Measurement. */ export const measureTextHeight = (function() { + /** + * @type {HTMLDivElement} + */ let div; const heights = textHeights; return function(font) { diff --git a/src/ol/source/TileWMS.js b/src/ol/source/TileWMS.js index ee39d13e1d..513e7ae132 100644 --- a/src/ol/source/TileWMS.js +++ b/src/ol/source/TileWMS.js @@ -81,7 +81,7 @@ class TileWMS extends TileImage { */ constructor(opt_options) { - const options = opt_options ? opt_options : {}; + const options = opt_options ? opt_options : /** @type {Options} */ ({}); const params = options.params || {}; diff --git a/src/ol/structs/LRUCache.js b/src/ol/structs/LRUCache.js index 29627c6119..3d9c89799a 100644 --- a/src/ol/structs/LRUCache.js +++ b/src/ol/structs/LRUCache.js @@ -96,7 +96,7 @@ class LRUCache extends EventTarget { /** - * @param {function(T, string, LRUCache): ?} f The function + * @param {function(T, string, LRUCache): ?} f The function * to call for every entry from the oldest to the newer. This function takes * 3 arguments (the entry value, the entry key and the LRUCache object). * The return value is ignored. From f67476dd8fbdd63800003f4511071d0bddf14491 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 27 Sep 2019 13:57:58 +0200 Subject: [PATCH 4/4] Mark properties as nullable --- src/ol/Geolocation.js | 2 +- src/ol/Image.js | 2 +- src/ol/ImageTile.js | 2 +- src/ol/MapBrowserEvent.js | 4 ++-- src/ol/PluggableMap.js | 4 ++-- src/ol/control/MousePosition.js | 2 +- src/ol/control/ZoomToExtent.js | 2 +- src/ol/format/TopoJSON.js | 2 +- src/ol/interaction/DragAndDrop.js | 2 +- src/ol/reproj/Tile.js | 2 +- src/ol/style/IconImage.js | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ol/Geolocation.js b/src/ol/Geolocation.js index b281d6f0b7..9e771de3e9 100644 --- a/src/ol/Geolocation.js +++ b/src/ol/Geolocation.js @@ -98,7 +98,7 @@ class Geolocation extends BaseObject { /** * The unprojected (EPSG:4326) device position. * @private - * @type {import("./coordinate.js").Coordinate} + * @type {?import("./coordinate.js").Coordinate} */ this.position_ = null; diff --git a/src/ol/Image.js b/src/ol/Image.js index f9d39dc8b3..a7f0797b0e 100644 --- a/src/ol/Image.js +++ b/src/ol/Image.js @@ -59,7 +59,7 @@ class ImageWrapper extends ImageBase { /** * @private - * @type {function():void} + * @type {?function():void} */ this.unlisten_ = null; diff --git a/src/ol/ImageTile.js b/src/ol/ImageTile.js index 8d934f7c39..64b90fa22a 100644 --- a/src/ol/ImageTile.js +++ b/src/ol/ImageTile.js @@ -46,7 +46,7 @@ class ImageTile extends Tile { /** * @private - * @type {function():void} + * @type {?function():void} */ this.unlisten_ = null; diff --git a/src/ol/MapBrowserEvent.js b/src/ol/MapBrowserEvent.js index 956c639f24..dc301946b7 100644 --- a/src/ol/MapBrowserEvent.js +++ b/src/ol/MapBrowserEvent.js @@ -31,13 +31,13 @@ class MapBrowserEvent extends MapEvent { /** * The map pixel relative to the viewport corresponding to the original browser event. - * @type {import("./pixel.js").Pixel} + * @type {?import("./pixel.js").Pixel} */ this.pixel_ = null; /** * The coordinate in the user projection corresponding to the original browser event. - * @type {import("./coordinate.js").Coordinate} + * @type {?import("./coordinate.js").Coordinate} */ this.coordinate_ = null; diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index a65da29671..a82fec0687 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -232,7 +232,7 @@ class PluggableMap extends BaseObject { /** * @private - * @type {Array} + * @type {?Array} */ this.layerGroupPropertyListenerKeys_ = null; @@ -292,7 +292,7 @@ class PluggableMap extends BaseObject { /** * @private - * @type {Array} + * @type {?Array} */ this.keyHandlerKeys_ = null; diff --git a/src/ol/control/MousePosition.js b/src/ol/control/MousePosition.js index 3d97fe04d1..cb96bf3514 100644 --- a/src/ol/control/MousePosition.js +++ b/src/ol/control/MousePosition.js @@ -97,7 +97,7 @@ class MousePosition extends Control { /** * @private - * @type {import("../proj/Projection.js").default} + * @type {?import("../proj/Projection.js").default} */ this.mapProjection_ = null; diff --git a/src/ol/control/ZoomToExtent.js b/src/ol/control/ZoomToExtent.js index 32f59de1a9..6c3142a6c0 100644 --- a/src/ol/control/ZoomToExtent.js +++ b/src/ol/control/ZoomToExtent.js @@ -41,7 +41,7 @@ class ZoomToExtent extends Control { }); /** - * @type {import("../extent.js").Extent} + * @type {?import("../extent.js").Extent} * @protected */ this.extent = options.extent ? options.extent : null; diff --git a/src/ol/format/TopoJSON.js b/src/ol/format/TopoJSON.js index 10f00ab865..c8cc330cf7 100644 --- a/src/ol/format/TopoJSON.js +++ b/src/ol/format/TopoJSON.js @@ -73,7 +73,7 @@ class TopoJSON extends JSONFeature { /** * @private - * @type {Array} + * @type {?Array} */ this.layers_ = options.layers ? options.layers : null; diff --git a/src/ol/interaction/DragAndDrop.js b/src/ol/interaction/DragAndDrop.js index f4921ba2b3..5cb69e3b08 100644 --- a/src/ol/interaction/DragAndDrop.js +++ b/src/ol/interaction/DragAndDrop.js @@ -115,7 +115,7 @@ class DragAndDrop extends Interaction { /** * @private - * @type {Array} + * @type {?Array} */ this.dropListenKeys_ = null; diff --git a/src/ol/reproj/Tile.js b/src/ol/reproj/Tile.js index e2afe70093..909b125e7e 100644 --- a/src/ol/reproj/Tile.js +++ b/src/ol/reproj/Tile.js @@ -104,7 +104,7 @@ class ReprojTile extends Tile { /** * @private - * @type {Array} + * @type {?Array} */ this.sourcesListenerKeys_ = null; diff --git a/src/ol/style/IconImage.js b/src/ol/style/IconImage.js index 940b946f83..d2361e5bb7 100644 --- a/src/ol/style/IconImage.js +++ b/src/ol/style/IconImage.js @@ -53,7 +53,7 @@ class IconImage extends EventTarget { /** * @private - * @type {function():void} + * @type {?function():void} */ this.unlisten_ = null;