Improve some null types to prepare for strictNullChecks
This commit is contained in:
@@ -38,7 +38,7 @@ class ZoomToExtent extends Control {
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {?import("../extent.js").Extent}
|
||||
* @type {?import("../extent.js").Extent|null}
|
||||
* @protected
|
||||
*/
|
||||
this.extent = options.extent ? options.extent : null;
|
||||
|
||||
@@ -83,7 +83,7 @@ export function replaceNode(newNode, oldNode) {
|
||||
|
||||
/**
|
||||
* @param {Node} node The node to remove.
|
||||
* @return {Node} The node that was removed or null.
|
||||
* @return {Node|null} The node that was removed or null.
|
||||
*/
|
||||
export function removeNode(node) {
|
||||
return node && node.parentNode ? node.parentNode.removeChild(node) : null;
|
||||
|
||||
@@ -80,7 +80,7 @@ class MVT extends FeatureFormat {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<string>}
|
||||
* @type {Array<string>|null}
|
||||
*/
|
||||
this.layers_ = options.layers ? options.layers : null;
|
||||
|
||||
|
||||
@@ -54,20 +54,20 @@ class WMSGetFeatureInfo extends XMLFeature {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<string>}
|
||||
* @type {Array<string>|null}
|
||||
*/
|
||||
this.layers_ = options.layers ? options.layers : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Array<string>} layers
|
||||
* @return {Array<string>|null} layers
|
||||
*/
|
||||
getLayers() {
|
||||
return this.layers_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<string>} layers Layers to parse.
|
||||
* @param {Array<string>|null} layers Layers to parse.
|
||||
*/
|
||||
setLayers(layers) {
|
||||
this.layers_ = layers;
|
||||
|
||||
@@ -168,7 +168,7 @@ class DragAndDrop extends Interaction {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLElement}
|
||||
* @type {HTMLElement|null}
|
||||
*/
|
||||
this.target = options.target ? options.target : null;
|
||||
}
|
||||
|
||||
@@ -257,14 +257,14 @@ class Draw extends PointerInteraction {
|
||||
|
||||
/**
|
||||
* Target source for drawn features.
|
||||
* @type {VectorSource}
|
||||
* @type {VectorSource|null}
|
||||
* @private
|
||||
*/
|
||||
this.source_ = options.source ? options.source : null;
|
||||
|
||||
/**
|
||||
* Target collection for drawn features.
|
||||
* @type {import("../Collection.js").default<Feature>}
|
||||
* @type {import("../Collection.js").default<Feature>|null}
|
||||
* @private
|
||||
*/
|
||||
this.features_ = options.features ? options.features : null;
|
||||
@@ -1022,7 +1022,7 @@ class Draw extends PointerInteraction {
|
||||
|
||||
/**
|
||||
* Stop drawing without adding the sketch feature to the target layer.
|
||||
* @return {Feature<import("../geom/SimpleGeometry.js").default>} The sketch feature (or null if none).
|
||||
* @return {Feature<import("../geom/SimpleGeometry.js").default>|null} The sketch feature (or null if none).
|
||||
* @private
|
||||
*/
|
||||
abortDrawing_() {
|
||||
|
||||
@@ -115,7 +115,7 @@ class Snap extends PointerInteraction {
|
||||
super(pointerOptions);
|
||||
|
||||
/**
|
||||
* @type {import("../source/Vector.js").default}
|
||||
* @type {import("../source/Vector.js").default|null}
|
||||
* @private
|
||||
*/
|
||||
this.source_ = options.source ? options.source : null;
|
||||
@@ -133,7 +133,7 @@ class Snap extends PointerInteraction {
|
||||
this.edge_ = options.edge !== undefined ? options.edge : true;
|
||||
|
||||
/**
|
||||
* @type {import("../Collection.js").default<import("../Feature.js").default>}
|
||||
* @type {import("../Collection.js").default<import("../Feature.js").default>|null}
|
||||
* @private
|
||||
*/
|
||||
this.features_ = options.features ? options.features : null;
|
||||
|
||||
@@ -169,7 +169,7 @@ class Translate extends PointerInteraction {
|
||||
this.startCoordinate_ = null;
|
||||
|
||||
/**
|
||||
* @type {Collection<import("../Feature.js").default>}
|
||||
* @type {Collection<import("../Feature.js").default>|null}
|
||||
* @private
|
||||
*/
|
||||
this.features_ = options.features !== undefined ? options.features : null;
|
||||
|
||||
@@ -119,7 +119,7 @@ class BaseLayer extends BaseObject {
|
||||
* @private
|
||||
*/
|
||||
this.className_ =
|
||||
properties.className !== undefined ? options.className : 'ol-layer';
|
||||
properties.className !== undefined ? properties.className : 'ol-layer';
|
||||
delete properties.className;
|
||||
|
||||
this.setProperties(properties);
|
||||
@@ -288,7 +288,7 @@ class BaseLayer extends BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the backgrlound color.
|
||||
* Sets the background color.
|
||||
* @param {BackgroundColor} [opt_background] Background color.
|
||||
*/
|
||||
setBackground(opt_background) {
|
||||
|
||||
@@ -127,7 +127,7 @@ class ImageSource extends Source {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<number>}
|
||||
* @type {Array<number>|null}
|
||||
*/
|
||||
this.resolutions_ =
|
||||
options.resolutions !== undefined ? options.resolutions : null;
|
||||
@@ -146,7 +146,7 @@ class ImageSource extends Source {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Array<number>} Resolutions.
|
||||
* @return {Array<number>|null} Resolutions.
|
||||
*/
|
||||
getResolutions() {
|
||||
return this.resolutions_;
|
||||
|
||||
@@ -87,7 +87,7 @@ class Static extends ImageSource {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../size.js").Size}
|
||||
* @type {import("../size.js").Size|null}
|
||||
*/
|
||||
this.imageSize_ = options.imageSize ? options.imageSize : null;
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ class Source extends BaseObject {
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return {Array<number>|undefined} Resolutions.
|
||||
* @return {Array<number>|null} Resolutions.
|
||||
*/
|
||||
getResolutions() {
|
||||
return abstract();
|
||||
|
||||
@@ -93,14 +93,13 @@ class TileSource extends Source {
|
||||
options.tilePixelRatio !== undefined ? options.tilePixelRatio : 1;
|
||||
|
||||
/**
|
||||
* @type {import("../tilegrid/TileGrid.js").default}
|
||||
* @type {import("../tilegrid/TileGrid.js").default|null}
|
||||
*/
|
||||
this.tileGrid = options.tileGrid !== undefined ? options.tileGrid : null;
|
||||
|
||||
const tileSize = [256, 256];
|
||||
const tileGrid = options.tileGrid;
|
||||
if (tileGrid) {
|
||||
toSize(tileGrid.getTileSize(tileGrid.getMinZoom()), tileSize);
|
||||
if (this.tileGrid) {
|
||||
toSize(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()), tileSize);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,9 +232,12 @@ class TileSource extends Source {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Array<number>} Resolutions.
|
||||
* @return {Array<number>|null} Resolutions.
|
||||
*/
|
||||
getResolutions() {
|
||||
if (!this.tileGrid) {
|
||||
return null;
|
||||
}
|
||||
return this.tileGrid.getResolutions();
|
||||
}
|
||||
|
||||
@@ -254,7 +256,7 @@ class TileSource extends Source {
|
||||
|
||||
/**
|
||||
* Return the tile grid of the tile source.
|
||||
* @return {import("../tilegrid/TileGrid.js").default} Tile grid.
|
||||
* @return {import("../tilegrid/TileGrid.js").default|null} Tile grid.
|
||||
* @api
|
||||
*/
|
||||
getTileGrid() {
|
||||
|
||||
@@ -827,7 +827,7 @@ class VectorSource extends Source {
|
||||
* `source.getFeatureById(2)` will return a feature with id `'2'` or `2`.
|
||||
*
|
||||
* @param {string|number} id Feature identifier.
|
||||
* @return {import("../Feature.js").default<Geometry>} The feature (or `null` if not found).
|
||||
* @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found).
|
||||
* @api
|
||||
*/
|
||||
getFeatureById(id) {
|
||||
@@ -839,7 +839,7 @@ class VectorSource extends Source {
|
||||
* Get a feature by its internal unique identifier (using `getUid`).
|
||||
*
|
||||
* @param {string} uid Feature identifier.
|
||||
* @return {import("../Feature.js").default<Geometry>} The feature (or `null` if not found).
|
||||
* @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found).
|
||||
*/
|
||||
getFeatureByUid(uid) {
|
||||
const feature = this.uidIndex_[uid];
|
||||
|
||||
@@ -142,7 +142,7 @@ class VectorTile extends UrlTile {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../format/Feature.js").default}
|
||||
* @type {import("../format/Feature.js").default|null}
|
||||
*/
|
||||
this.format_ = options.format ? options.format : null;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [color=null] A color, gradient or pattern.
|
||||
* @property {import("../color.js").Color|import("../colorlike.js").ColorLike|null} [color=null] A color, gradient or pattern.
|
||||
* See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats.
|
||||
* Default null; if null, the Canvas/renderer default black will be used.
|
||||
*/
|
||||
@@ -23,7 +23,7 @@ class Fill {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../color.js").Color|import("../colorlike.js").ColorLike}
|
||||
* @type {import("../color.js").Color|import("../colorlike.js").ColorLike|null}
|
||||
*/
|
||||
this.color_ = options.color !== undefined ? options.color : null;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class Fill {
|
||||
|
||||
/**
|
||||
* Get the fill color.
|
||||
* @return {import("../color.js").Color|import("../colorlike.js").ColorLike} Color.
|
||||
* @return {import("../color.js").Color|import("../colorlike.js").ColorLike|null} Color.
|
||||
* @api
|
||||
*/
|
||||
getColor() {
|
||||
@@ -52,7 +52,7 @@ class Fill {
|
||||
/**
|
||||
* Set the color.
|
||||
*
|
||||
* @param {import("../color.js").Color|import("../colorlike.js").ColorLike} color Color.
|
||||
* @param {import("../color.js").Color|import("../colorlike.js").ColorLike|null} color Color.
|
||||
* @api
|
||||
*/
|
||||
setColor(color) {
|
||||
|
||||
@@ -455,7 +455,7 @@ export function toFunction(obj) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Array<Style>}
|
||||
* @type {Array<Style>|null}
|
||||
*/
|
||||
let defaultStyles = null;
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ class Text {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<number>}
|
||||
* @type {Array<number>|null}
|
||||
*/
|
||||
this.padding_ = options.padding === undefined ? null : options.padding;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ class Text {
|
||||
backgroundStroke: this.getBackgroundStroke()
|
||||
? this.getBackgroundStroke().clone()
|
||||
: undefined,
|
||||
padding: this.getPadding(),
|
||||
padding: this.getPadding() || undefined,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ class Text {
|
||||
|
||||
/**
|
||||
* Get the padding for the text.
|
||||
* @return {Array<number>} Padding.
|
||||
* @return {Array<number>|null} Padding.
|
||||
* @api
|
||||
*/
|
||||
getPadding() {
|
||||
@@ -530,7 +530,7 @@ class Text {
|
||||
/**
|
||||
* Set the padding (`[top, right, bottom, left]`).
|
||||
*
|
||||
* @param {!Array<number>} padding Padding.
|
||||
* @param {Array<number>|null} padding Padding.
|
||||
* @api
|
||||
*/
|
||||
setPadding(padding) {
|
||||
|
||||
@@ -117,7 +117,7 @@ class TileGrid {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../coordinate.js").Coordinate}
|
||||
* @type {import("../coordinate.js").Coordinate|null}
|
||||
*/
|
||||
this.origin_ = options.origin !== undefined ? options.origin : null;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ worker.onmessage = (event) => {
|
||||
const indexBuffer = new Uint32Array(indicesCount);
|
||||
const vertexBuffer = new Float32Array(verticesCount);
|
||||
|
||||
let bufferPositions = null;
|
||||
let bufferPositions;
|
||||
for (let i = 0; i < renderInstructions.length; i += instructionsCount) {
|
||||
bufferPositions = writePointFeatureToBuffers(
|
||||
renderInstructions,
|
||||
|
||||
Reference in New Issue
Block a user