Merge pull request #13334 from EvertEt/strictnullchecks-4
Improve some null types for strictNullChecks
This commit is contained in:
@@ -59,7 +59,7 @@ class MapBrowserEventHandler extends Target {
|
|||||||
/**
|
/**
|
||||||
* The most recent "down" type event (or null if none have occurred).
|
* The most recent "down" type event (or null if none have occurred).
|
||||||
* Set on pointerdown.
|
* Set on pointerdown.
|
||||||
* @type {PointerEvent}
|
* @type {PointerEvent|null}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.down_ = null;
|
this.down_ = null;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ const fontRegExMatchIndex = [
|
|||||||
* Get the list of font families from a font spec. Note that this doesn't work
|
* Get the list of font families from a font spec. Note that this doesn't work
|
||||||
* for font families that have commas in them.
|
* for font families that have commas in them.
|
||||||
* @param {string} fontSpec The CSS font property.
|
* @param {string} fontSpec The CSS font property.
|
||||||
* @return {FontParameters} The font parameters (or null if the input spec is invalid).
|
* @return {FontParameters|null} The font parameters (or null if the input spec is invalid).
|
||||||
*/
|
*/
|
||||||
export const getFontParameters = function (fontSpec) {
|
export const getFontParameters = function (fontSpec) {
|
||||||
const match = fontSpec.match(fontRegEx);
|
const match = fontSpec.match(fontRegEx);
|
||||||
|
|||||||
@@ -195,13 +195,13 @@ const KML_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
|
|||||||
let DEFAULT_COLOR;
|
let DEFAULT_COLOR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Fill}
|
* @type {Fill|null}
|
||||||
*/
|
*/
|
||||||
let DEFAULT_FILL_STYLE = null;
|
let DEFAULT_FILL_STYLE = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default fill style (or null if not yet set).
|
* Get the default fill style (or null if not yet set).
|
||||||
* @return {Fill} The default fill style.
|
* @return {Fill|null} The default fill style.
|
||||||
*/
|
*/
|
||||||
export function getDefaultFillStyle() {
|
export function getDefaultFillStyle() {
|
||||||
return DEFAULT_FILL_STYLE;
|
return DEFAULT_FILL_STYLE;
|
||||||
@@ -233,13 +233,13 @@ let DEFAULT_IMAGE_STYLE_SIZE;
|
|||||||
let DEFAULT_IMAGE_STYLE_SRC;
|
let DEFAULT_IMAGE_STYLE_SRC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import("../style/Image.js").default}
|
* @type {import("../style/Image.js").default|null}
|
||||||
*/
|
*/
|
||||||
let DEFAULT_IMAGE_STYLE = null;
|
let DEFAULT_IMAGE_STYLE = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default image style (or null if not yet set).
|
* Get the default image style (or null if not yet set).
|
||||||
* @return {import("../style/Image.js").default} The default image style.
|
* @return {import("../style/Image.js").default|null} The default image style.
|
||||||
*/
|
*/
|
||||||
export function getDefaultImageStyle() {
|
export function getDefaultImageStyle() {
|
||||||
return DEFAULT_IMAGE_STYLE;
|
return DEFAULT_IMAGE_STYLE;
|
||||||
@@ -251,13 +251,13 @@ export function getDefaultImageStyle() {
|
|||||||
let DEFAULT_NO_IMAGE_STYLE;
|
let DEFAULT_NO_IMAGE_STYLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Stroke}
|
* @type {Stroke|null}
|
||||||
*/
|
*/
|
||||||
let DEFAULT_STROKE_STYLE = null;
|
let DEFAULT_STROKE_STYLE = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default stroke style (or null if not yet set).
|
* Get the default stroke style (or null if not yet set).
|
||||||
* @return {Stroke} The default stroke style.
|
* @return {Stroke|null} The default stroke style.
|
||||||
*/
|
*/
|
||||||
export function getDefaultStrokeStyle() {
|
export function getDefaultStrokeStyle() {
|
||||||
return DEFAULT_STROKE_STYLE;
|
return DEFAULT_STROKE_STYLE;
|
||||||
@@ -269,39 +269,39 @@ export function getDefaultStrokeStyle() {
|
|||||||
let DEFAULT_TEXT_STROKE_STYLE;
|
let DEFAULT_TEXT_STROKE_STYLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Text}
|
* @type {Text|null}
|
||||||
*/
|
*/
|
||||||
let DEFAULT_TEXT_STYLE = null;
|
let DEFAULT_TEXT_STYLE = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default text style (or null if not yet set).
|
* Get the default text style (or null if not yet set).
|
||||||
* @return {Text} The default text style.
|
* @return {Text|null} The default text style.
|
||||||
*/
|
*/
|
||||||
export function getDefaultTextStyle() {
|
export function getDefaultTextStyle() {
|
||||||
return DEFAULT_TEXT_STYLE;
|
return DEFAULT_TEXT_STYLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Style}
|
* @type {Style|null}
|
||||||
*/
|
*/
|
||||||
let DEFAULT_STYLE = null;
|
let DEFAULT_STYLE = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default style (or null if not yet set).
|
* Get the default style (or null if not yet set).
|
||||||
* @return {Style} The default style.
|
* @return {Style|null} The default style.
|
||||||
*/
|
*/
|
||||||
export function getDefaultStyle() {
|
export function getDefaultStyle() {
|
||||||
return DEFAULT_STYLE;
|
return DEFAULT_STYLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array<Style>}
|
* @type {Array<Style>|null}
|
||||||
*/
|
*/
|
||||||
let DEFAULT_STYLE_ARRAY = null;
|
let DEFAULT_STYLE_ARRAY = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default style array (or null if not yet set).
|
* Get the default style array (or null if not yet set).
|
||||||
* @return {Array<Style>} The default style.
|
* @return {Array<Style>|null} The default style.
|
||||||
*/
|
*/
|
||||||
export function getDefaultStyleArray() {
|
export function getDefaultStyleArray() {
|
||||||
return DEFAULT_STYLE_ARRAY;
|
return DEFAULT_STYLE_ARRAY;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class WkbReader {
|
|||||||
this.isLittleEndian_ = false;
|
this.isLittleEndian_ = false;
|
||||||
this.hasZ_ = false;
|
this.hasZ_ = false;
|
||||||
this.hasM_ = false;
|
this.hasM_ = false;
|
||||||
/** @type {number} */
|
/** @type {number|null} */
|
||||||
this.srid_ = null;
|
this.srid_ = null;
|
||||||
|
|
||||||
this.layout_ = GeometryLayout.XY;
|
this.layout_ = GeometryLayout.XY;
|
||||||
@@ -356,7 +356,7 @@ class WkbReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number} SRID in the EWKB. `null` if not defined.
|
* @return {number|null} SRID in the EWKB. `null` if not defined.
|
||||||
*/
|
*/
|
||||||
getSrid() {
|
getSrid() {
|
||||||
return this.srid_;
|
return this.srid_;
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class LineString extends SimpleGeometry {
|
|||||||
*
|
*
|
||||||
* @param {number} m M.
|
* @param {number} m M.
|
||||||
* @param {boolean} [opt_extrapolate] Extrapolate. Default is `false`.
|
* @param {boolean} [opt_extrapolate] Extrapolate. Default is `false`.
|
||||||
* @return {import("../coordinate.js").Coordinate} Coordinate.
|
* @return {import("../coordinate.js").Coordinate|null} Coordinate.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
getCoordinateAtM(m, opt_extrapolate) {
|
getCoordinateAtM(m, opt_extrapolate) {
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class MultiLineString extends SimpleGeometry {
|
|||||||
* @param {number} m M.
|
* @param {number} m M.
|
||||||
* @param {boolean} [opt_extrapolate] Extrapolate. Default is `false`.
|
* @param {boolean} [opt_extrapolate] Extrapolate. Default is `false`.
|
||||||
* @param {boolean} [opt_interpolate] Interpolate. Default is `false`.
|
* @param {boolean} [opt_interpolate] Interpolate. Default is `false`.
|
||||||
* @return {import("../coordinate.js").Coordinate} Coordinate.
|
* @return {import("../coordinate.js").Coordinate|null} Coordinate.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
getCoordinateAtM(m, opt_extrapolate, opt_interpolate) {
|
getCoordinateAtM(m, opt_extrapolate, opt_interpolate) {
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ class Polygon extends SimpleGeometry {
|
|||||||
* at index `1` and beyond.
|
* at index `1` and beyond.
|
||||||
*
|
*
|
||||||
* @param {number} index Index.
|
* @param {number} index Index.
|
||||||
* @return {LinearRing} Linear ring.
|
* @return {LinearRing|null} Linear ring.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
getLinearRing(index) {
|
getLinearRing(index) {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export function interpolatePoint(
|
|||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @param {number} m M.
|
* @param {number} m M.
|
||||||
* @param {boolean} extrapolate Extrapolate.
|
* @param {boolean} extrapolate Extrapolate.
|
||||||
* @return {import("../../coordinate.js").Coordinate} Coordinate.
|
* @return {import("../../coordinate.js").Coordinate|null} Coordinate.
|
||||||
*/
|
*/
|
||||||
export function lineStringCoordinateAtM(
|
export function lineStringCoordinateAtM(
|
||||||
flatCoordinates,
|
flatCoordinates,
|
||||||
@@ -147,7 +147,7 @@ export function lineStringCoordinateAtM(
|
|||||||
* @param {number} m M.
|
* @param {number} m M.
|
||||||
* @param {boolean} extrapolate Extrapolate.
|
* @param {boolean} extrapolate Extrapolate.
|
||||||
* @param {boolean} interpolate Interpolate.
|
* @param {boolean} interpolate Interpolate.
|
||||||
* @return {import("../../coordinate.js").Coordinate} Coordinate.
|
* @return {import("../../coordinate.js").Coordinate|null} Coordinate.
|
||||||
*/
|
*/
|
||||||
export function lineStringsCoordinateAtM(
|
export function lineStringsCoordinateAtM(
|
||||||
flatCoordinates,
|
flatCoordinates,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {rotate} from './transform.js';
|
|||||||
* @param {string} font The font.
|
* @param {string} font The font.
|
||||||
* @param {Object<string, number>} cache A cache of measured widths.
|
* @param {Object<string, number>} cache A cache of measured widths.
|
||||||
* @param {number} rotation Rotation to apply to the flatCoordinates to determine whether text needs to be reversed.
|
* @param {number} rotation Rotation to apply to the flatCoordinates to determine whether text needs to be reversed.
|
||||||
* @return {Array<Array<*>>} The result array (or null if `maxAngle` was
|
* @return {Array<Array<*>>|null} The result array (or null if `maxAngle` was
|
||||||
* exceeded). Entries of the array are x, y, anchorX, angle, chunk.
|
* exceeded). Entries of the array are x, y, anchorX, angle, chunk.
|
||||||
*/
|
*/
|
||||||
export function drawTextOnPath(
|
export function drawTextOnPath(
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class Interaction extends BaseObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {import("../PluggableMap.js").default}
|
* @type {import("../PluggableMap.js").default|null}
|
||||||
*/
|
*/
|
||||||
this.map_ = null;
|
this.map_ = null;
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ class Interaction extends BaseObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the map associated with this interaction.
|
* Get the map associated with this interaction.
|
||||||
* @return {import("../PluggableMap.js").default} Map.
|
* @return {import("../PluggableMap.js").default|null} Map.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
getMap() {
|
getMap() {
|
||||||
@@ -116,7 +116,7 @@ class Interaction extends BaseObject {
|
|||||||
* Remove the interaction from its current map and attach it to the new map.
|
* Remove the interaction from its current map and attach it to the new map.
|
||||||
* Subclasses may set up event handlers to get notified about changes to
|
* Subclasses may set up event handlers to get notified about changes to
|
||||||
* the map here.
|
* the map here.
|
||||||
* @param {import("../PluggableMap.js").default} map Map.
|
* @param {import("../PluggableMap.js").default|null} map Map.
|
||||||
*/
|
*/
|
||||||
setMap(map) {
|
setMap(map) {
|
||||||
this.map_ = map;
|
this.map_ = map;
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ class Select extends Interaction {
|
|||||||
/**
|
/**
|
||||||
* Remove the interaction from its current map, if any, and attach it to a new
|
* Remove the interaction from its current map, if any, and attach it to a new
|
||||||
* map, if any. Pass `null` to just remove the interaction from the current map.
|
* map, if any. Pass `null` to just remove the interaction from the current map.
|
||||||
* @param {import("../PluggableMap.js").default} map Map.
|
* @param {import("../PluggableMap.js").default|null} map Map.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
setMap(map) {
|
setMap(map) {
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class Layer extends BaseLayer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the layer source.
|
* Get the layer source.
|
||||||
* @return {SourceType} The layer source (or `null` if not yet set).
|
* @return {SourceType|null} The layer source (or `null` if not yet set).
|
||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@@ -197,7 +197,7 @@ class Layer extends BaseLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {SourceType} The source being rendered.
|
* @return {SourceType|null} The source being rendered.
|
||||||
*/
|
*/
|
||||||
getRenderSource() {
|
getRenderSource() {
|
||||||
return this.getSource();
|
return this.getSource();
|
||||||
@@ -333,7 +333,7 @@ class Layer extends BaseLayer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the layer source.
|
* Set the layer source.
|
||||||
* @param {SourceType} source The layer source.
|
* @param {SourceType|null} source The layer source.
|
||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ export function addProjections(projections) {
|
|||||||
* @param {ProjectionLike} projectionLike Either a code string which is
|
* @param {ProjectionLike} projectionLike Either a code string which is
|
||||||
* a combination of authority and identifier such as "EPSG:4326", or an
|
* a combination of authority and identifier such as "EPSG:4326", or an
|
||||||
* existing projection object, or undefined.
|
* existing projection object, or undefined.
|
||||||
* @return {Projection} Projection object, or null if not in list.
|
* @return {Projection|null} Projection object, or null if not in list.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
export function get(projectionLike) {
|
export function get(projectionLike) {
|
||||||
@@ -533,7 +533,7 @@ export function transformWithProjections(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {?Projection}
|
* @type {Projection|null}
|
||||||
*/
|
*/
|
||||||
let userProjection = null;
|
let userProjection = null;
|
||||||
|
|
||||||
@@ -560,7 +560,7 @@ export function clearUserProjection() {
|
|||||||
* Get the projection for coordinates supplied from and returned by API methods.
|
* Get the projection for coordinates supplied from and returned by API methods.
|
||||||
* Note that this method is not yet a part of the stable API. Support for user
|
* Note that this method is not yet a part of the stable API. Support for user
|
||||||
* projections is not yet complete and should be considered experimental.
|
* projections is not yet complete and should be considered experimental.
|
||||||
* @return {?Projection} The user projection (or null if not set).
|
* @return {Projection|null} The user projection (or null if not set).
|
||||||
*/
|
*/
|
||||||
export function getUserProjection() {
|
export function getUserProjection() {
|
||||||
return userProjection;
|
return userProjection;
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ class Source extends BaseObject {
|
|||||||
/**
|
/**
|
||||||
* Turns the attributions option into an attributions function.
|
* Turns the attributions option into an attributions function.
|
||||||
* @param {AttributionLike|undefined} attributionLike The attribution option.
|
* @param {AttributionLike|undefined} attributionLike The attribution option.
|
||||||
* @return {?Attribution} An attribution function (or null).
|
* @return {Attribution|null} An attribution function (or null).
|
||||||
*/
|
*/
|
||||||
function adaptAttributions(attributionLike) {
|
function adaptAttributions(attributionLike) {
|
||||||
if (!attributionLike) {
|
if (!attributionLike) {
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ class VectorSource extends Source {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Collection<import("../Feature.js").default<Geometry>>}
|
* @type {Collection<import("../Feature.js").default<Geometry>>|null}
|
||||||
*/
|
*/
|
||||||
this.featuresCollection_ = null;
|
this.featuresCollection_ = null;
|
||||||
|
|
||||||
@@ -683,7 +683,7 @@ class VectorSource extends Source {
|
|||||||
* Get the features collection associated with this source. Will be `null`
|
* Get the features collection associated with this source. Will be `null`
|
||||||
* unless the source was configured with `useSpatialIndex` set to `false`, or
|
* unless the source was configured with `useSpatialIndex` set to `false`, or
|
||||||
* with an {@link module:ol/Collection} as `features`.
|
* with an {@link module:ol/Collection} as `features`.
|
||||||
* @return {Collection<import("../Feature.js").default<Geometry>>} The collection of features.
|
* @return {Collection<import("../Feature.js").default<Geometry>>|null} The collection of features.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
getFeaturesCollection() {
|
getFeaturesCollection() {
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ export default WMTS;
|
|||||||
* - format - {string} Image format for the layer. Default is the first
|
* - format - {string} Image format for the layer. Default is the first
|
||||||
* format returned in the GetCapabilities response.
|
* format returned in the GetCapabilities response.
|
||||||
* - crossOrigin - {string|null|undefined} Cross origin. Default is `undefined`.
|
* - crossOrigin - {string|null|undefined} Cross origin. Default is `undefined`.
|
||||||
* @return {?Options} WMTS source options object or `null` if the layer was not found.
|
* @return {Options|null} WMTS source options object or `null` if the layer was not found.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
export function optionsFromCapabilities(wmtsCap, config) {
|
export function optionsFromCapabilities(wmtsCap, config) {
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ class WebGLHelper extends Disposable {
|
|||||||
* Get a WebGL extension. If the extension is not supported, null is returned.
|
* Get a WebGL extension. If the extension is not supported, null is returned.
|
||||||
* Extensions are cached after they are enabled for the first time.
|
* Extensions are cached after they are enabled for the first time.
|
||||||
* @param {string} name The extension name.
|
* @param {string} name The extension name.
|
||||||
* @return {Object} The extension or null if not supported.
|
* @return {Object|null} The extension or null if not supported.
|
||||||
*/
|
*/
|
||||||
getExtension(name) {
|
getExtension(name) {
|
||||||
if (name in this.extensionCache_) {
|
if (name in this.extensionCache_) {
|
||||||
|
|||||||
Reference in New Issue
Block a user