Merge pull request #10042 from fredj/better_typing

Better typing
This commit is contained in:
Frédéric Junod
2019-09-27 16:39:26 +02:00
committed by GitHub
18 changed files with 30 additions and 24 deletions

View File

@@ -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;

View File

@@ -59,7 +59,7 @@ class ImageWrapper extends ImageBase {
/**
* @private
* @type {function():void}
* @type {?function():void}
*/
this.unlisten_ = null;

View File

@@ -46,7 +46,7 @@ class ImageTile extends Tile {
/**
* @private
* @type {function():void}
* @type {?function():void}
*/
this.unlisten_ = null;

View File

@@ -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;

View File

@@ -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
*/

View File

@@ -232,7 +232,7 @@ class PluggableMap extends BaseObject {
/**
* @private
* @type {Array<import("./events.js").EventsKey>}
* @type {?Array<import("./events.js").EventsKey>}
*/
this.layerGroupPropertyListenerKeys_ = null;
@@ -292,7 +292,7 @@ class PluggableMap extends BaseObject {
/**
* @private
* @type {Array<import("./events.js").EventsKey>}
* @type {?Array<import("./events.js").EventsKey>}
*/
this.keyHandlerKeys_ = null;
@@ -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,
/**
@@ -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);
}

View File

@@ -97,7 +97,7 @@ class MousePosition extends Control {
/**
* @private
* @type {import("../proj/Projection.js").default}
* @type {?import("../proj/Projection.js").default}
*/
this.mapProjection_ = null;

View File

@@ -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;

View File

@@ -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<string, FontParameters>}

View File

@@ -73,7 +73,7 @@ class TopoJSON extends JSONFeature {
/**
* @private
* @type {Array<string>}
* @type {?Array<string>}
*/
this.layers_ = options.layers ? options.layers : null;

View File

@@ -115,7 +115,7 @@ class DragAndDrop extends Interaction {
/**
* @private
* @type {Array<import("../events.js").EventsKey>}
* @type {?Array<import("../events.js").EventsKey>}
*/
this.dropListenKeys_ = null;

View File

@@ -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) {

View File

@@ -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 || {};

View File

@@ -104,7 +104,7 @@ class ReprojTile extends Tile {
/**
* @private
* @type {Array<import("../events.js").EventsKey>}
* @type {?Array<import("../events.js").EventsKey>}
*/
this.sourcesListenerKeys_ = null;

View File

@@ -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 || {};

View File

@@ -96,7 +96,7 @@ class LRUCache extends EventTarget {
/**
* @param {function(T, string, LRUCache): ?} f The function
* @param {function(T, string, LRUCache<T>): ?} 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.

View File

@@ -53,7 +53,7 @@ class IconImage extends EventTarget {
/**
* @private
* @type {function():void}
* @type {?function():void}
*/
this.unlisten_ = null;

View File

@@ -101,7 +101,7 @@ const DEFAULT_FRAGMENT_SHADER = `
class WebGLPostProcessingPass {
/**
* @param {Options=} options Options.
* @param {Options} options Options.
*/
constructor(options) {
this.gl_ = options.webGlContext;