From cdb3e1c5298a6e3de40e62bb211cd4f4a62abee9 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 9 May 2018 15:46:39 +0200 Subject: [PATCH 1/4] Fix HTML Canvas typing issues --- src/ol/ImageCanvas.js | 2 +- src/ol/dom.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/ImageCanvas.js b/src/ol/ImageCanvas.js index c848a55077..55374de5a3 100644 --- a/src/ol/ImageCanvas.js +++ b/src/ol/ImageCanvas.js @@ -94,7 +94,7 @@ ImageCanvas.prototype.load = function() { /** - * @inheritDoc + * @return {HTMLCanvasElement} Canvas element. */ ImageCanvas.prototype.getImage = function() { return this.canvas_; diff --git a/src/ol/dom.js b/src/ol/dom.js index ee58409535..52c46ada47 100644 --- a/src/ol/dom.js +++ b/src/ol/dom.js @@ -10,14 +10,14 @@ * @return {CanvasRenderingContext2D} The context. */ export function createCanvasContext2D(opt_width, opt_height) { - const canvas = document.createElement('CANVAS'); + const canvas = /** @type {HTMLCanvasElement} */ (document.createElement('CANVAS')); if (opt_width) { canvas.width = opt_width; } if (opt_height) { canvas.height = opt_height; } - return canvas.getContext('2d'); + return /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d')); } From 0d99fc1f989d6b7c485c0f0e22d55fa0fa29dc88 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 9 May 2018 16:10:39 +0200 Subject: [PATCH 2/4] Set format parameter to rbush function To remove the following closure compiler warning: ``` Function module$node_modules$rbush$index.default: called with 1 argument(s). Function requires at least 2 argument(s) and at most 2. ``` --- src/ol/renderer/canvas/VectorLayer.js | 2 +- src/ol/renderer/canvas/VectorTileLayer.js | 2 +- src/ol/structs/RBush.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/renderer/canvas/VectorLayer.js b/src/ol/renderer/canvas/VectorLayer.js index bd3af95e42..da780638ff 100644 --- a/src/ol/renderer/canvas/VectorLayer.js +++ b/src/ol/renderer/canvas/VectorLayer.js @@ -29,7 +29,7 @@ const CanvasVectorLayerRenderer = function(vectorLayer) { * Declutter tree. * @private */ - this.declutterTree_ = vectorLayer.getDeclutter() ? rbush(9) : null; + this.declutterTree_ = vectorLayer.getDeclutter() ? rbush(9, undefined) : null; /** * @private diff --git a/src/ol/renderer/canvas/VectorTileLayer.js b/src/ol/renderer/canvas/VectorTileLayer.js index 9d903f45b7..e4a7035691 100644 --- a/src/ol/renderer/canvas/VectorTileLayer.js +++ b/src/ol/renderer/canvas/VectorTileLayer.js @@ -66,7 +66,7 @@ const CanvasVectorTileLayerRenderer = function(layer) { * Declutter tree. * @private */ - this.declutterTree_ = layer.getDeclutter() ? rbush(9) : null; + this.declutterTree_ = layer.getDeclutter() ? rbush(9, undefined) : null; /** * @private diff --git a/src/ol/structs/RBush.js b/src/ol/structs/RBush.js index ae57c7b486..dceecb0712 100644 --- a/src/ol/structs/RBush.js +++ b/src/ol/structs/RBush.js @@ -29,7 +29,7 @@ const RBush = function(opt_maxEntries) { /** * @private */ - this.rbush_ = rbush(opt_maxEntries); + this.rbush_ = rbush(opt_maxEntries, undefined); /** * A mapping between the objects added to this rbush wrapper From d987d99c932e782ca14eef71903fe9fbf87cef2c Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 9 May 2018 16:23:48 +0200 Subject: [PATCH 3/4] Don't allow null usedTiles to be passed to expireCache --- src/ol/source/Tile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/source/Tile.js b/src/ol/source/Tile.js index 79c3e598f7..c2f53d1b0a 100644 --- a/src/ol/source/Tile.js +++ b/src/ol/source/Tile.js @@ -107,7 +107,7 @@ TileSource.prototype.canExpireCache = function() { /** * @param {module:ol/proj/Projection} projection Projection. - * @param {Object.} usedTiles Used tiles. + * @param {!Object.} usedTiles Used tiles. */ TileSource.prototype.expireCache = function(projection, usedTiles) { const tileCache = this.getTileCacheForProjection(projection); From 14deb417a9a0262dbc353398ba373e98c44fc5a3 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 9 May 2018 16:30:41 +0200 Subject: [PATCH 4/4] Use MSPointerEvent event type in ol/pointer/MsSource --- src/ol/pointer/MsSource.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ol/pointer/MsSource.js b/src/ol/pointer/MsSource.js index 09f45d9903..2e1b7618c5 100644 --- a/src/ol/pointer/MsSource.js +++ b/src/ol/pointer/MsSource.js @@ -54,7 +54,7 @@ const MsSource = function(dispatcher) { /** * @const - * @type {!Object.} + * @type {!Object.} */ this.pointerMap = dispatcher.pointerMap; }; @@ -79,7 +79,7 @@ const POINTER_TYPES = [ * for the fake pointer event. * * @private - * @param {Event} inEvent The in event. + * @param {MSPointerEvent} inEvent The in event. * @return {Object} The copied event. */ MsSource.prototype.prepareEvent_ = function(inEvent) { @@ -105,7 +105,7 @@ MsSource.prototype.cleanup = function(pointerId) { /** * Handler for `msPointerDown`. * - * @param {Event} inEvent The in event. + * @param {MSPointerEvent} inEvent The in event. */ MsSource.prototype.msPointerDown = function(inEvent) { this.pointerMap[inEvent.pointerId.toString()] = inEvent; @@ -117,7 +117,7 @@ MsSource.prototype.msPointerDown = function(inEvent) { /** * Handler for `msPointerMove`. * - * @param {Event} inEvent The in event. + * @param {MSPointerEvent} inEvent The in event. */ MsSource.prototype.msPointerMove = function(inEvent) { const e = this.prepareEvent_(inEvent); @@ -128,7 +128,7 @@ MsSource.prototype.msPointerMove = function(inEvent) { /** * Handler for `msPointerUp`. * - * @param {Event} inEvent The in event. + * @param {MSPointerEvent} inEvent The in event. */ MsSource.prototype.msPointerUp = function(inEvent) { const e = this.prepareEvent_(inEvent); @@ -140,7 +140,7 @@ MsSource.prototype.msPointerUp = function(inEvent) { /** * Handler for `msPointerOut`. * - * @param {Event} inEvent The in event. + * @param {MSPointerEvent} inEvent The in event. */ MsSource.prototype.msPointerOut = function(inEvent) { const e = this.prepareEvent_(inEvent); @@ -151,7 +151,7 @@ MsSource.prototype.msPointerOut = function(inEvent) { /** * Handler for `msPointerOver`. * - * @param {Event} inEvent The in event. + * @param {MSPointerEvent} inEvent The in event. */ MsSource.prototype.msPointerOver = function(inEvent) { const e = this.prepareEvent_(inEvent); @@ -162,7 +162,7 @@ MsSource.prototype.msPointerOver = function(inEvent) { /** * Handler for `msPointerCancel`. * - * @param {Event} inEvent The in event. + * @param {MSPointerEvent} inEvent The in event. */ MsSource.prototype.msPointerCancel = function(inEvent) { const e = this.prepareEvent_(inEvent); @@ -174,7 +174,7 @@ MsSource.prototype.msPointerCancel = function(inEvent) { /** * Handler for `msLostPointerCapture`. * - * @param {Event} inEvent The in event. + * @param {MSPointerEvent} inEvent The in event. */ MsSource.prototype.msLostPointerCapture = function(inEvent) { const e = this.dispatcher.makeEvent('lostpointercapture', @@ -186,7 +186,7 @@ MsSource.prototype.msLostPointerCapture = function(inEvent) { /** * Handler for `msGotPointerCapture`. * - * @param {Event} inEvent The in event. + * @param {MSPointerEvent} inEvent The in event. */ MsSource.prototype.msGotPointerCapture = function(inEvent) { const e = this.dispatcher.makeEvent('gotpointercapture',