From bb3072153b47107509565ef5f26a39aaf8251b65 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 13 Mar 2018 12:33:35 +0100 Subject: [PATCH 1/2] Remove undefined type when the property is optional --- src/ol/View.js | 4 ++-- src/ol/control/Rotate.js | 14 +++++++------- src/ol/control/Zoom.js | 16 ++++++++-------- src/ol/control/ZoomSlider.js | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/ol/View.js b/src/ol/View.js index 2a168cf7fb..d470b80c5d 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -146,8 +146,8 @@ import Units from './proj/Units.js'; * the animation. * @property {ol.Coordinate|undefined} anchor Optional anchor to remained fixed * during a rotation or resolution animation. - * @property {number|undefined} [duration=1000] The duration of the animation in milliseconds. - * @property {undefined|function(number):number} [easing] The easing function used + * @property {number} [duration=1000] The duration of the animation in milliseconds. + * @property {function(number):number} [easing] The easing function used * during the animation (defaults to {@link ol.easing.inAndOut}). * The function will be called for each frame with a number representing a * fraction of the animation's duration. The function should return a number diff --git a/src/ol/control/Rotate.js b/src/ol/control/Rotate.js index 76a725c7e5..0ff894b973 100644 --- a/src/ol/control/Rotate.js +++ b/src/ol/control/Rotate.js @@ -12,17 +12,17 @@ import {inherits} from '../index.js'; /** * @typedef {Object} Options - * @property {string|undefined} [className='ol-rotate'] CSS class name. - * @property {string|Element|undefined} [label='⇧'] Text label to use for the rotate button. + * @property {string} [className='ol-rotate'] CSS class name. + * @property {string|Element} [label='⇧'] Text label to use for the rotate button. * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|undefined} [tipLabel='Reset rotation'] Text label to use for the rotate tip. - * @property {number|undefined} [duration=250] Animation duration in milliseconds. - * @property {boolean|undefined} [autoHide=true] Hide the control when rotation is 0. + * @property {string} [tipLabel='Reset rotation'] Text label to use for the rotate tip. + * @property {number} [duration=250] Animation duration in milliseconds. + * @property {boolean} [autoHide=true] Hide the control when rotation is 0. * @property {function(ol.MapEvent)|undefined} render Function called when the control should * be re-rendered. This is called in a `requestAnimationFrame` callback. - * @property {function()|undefined} [resetNorth] Function called when the control is clicked. + * @property {function()} [resetNorth] Function called when the control is clicked. * This will override the default `resetNorth`. - * @property {Element|string|undefined} [target] Specify a target if you want the control to be + * @property {Element|string} [target] Specify a target if you want the control to be * rendered outside of the map's viewport. */ diff --git a/src/ol/control/Zoom.js b/src/ol/control/Zoom.js index 6d27698ab9..2f5dac07fe 100644 --- a/src/ol/control/Zoom.js +++ b/src/ol/control/Zoom.js @@ -11,16 +11,16 @@ import {easeOut} from '../easing.js'; /** * @typedef {Object} Options - * @property {number|undefined} [duration=250] Animation duration in milliseconds. - * @property {string|undefined} [className='ol-zoom'] CSS class name. - * @property {string|Element|undefined} [zoomInLabel='+'] Text label to use for the zoom-in + * @property {number} [duration=250] Animation duration in milliseconds. + * @property {string} [className='ol-zoom'] CSS class name. + * @property {string|Element} [zoomInLabel='+'] Text label to use for the zoom-in * button. Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|Element|undefined} [zoomOutLabel='-'] Text label to use for the zoom-out button. + * @property {string|Element} [zoomOutLabel='-'] Text label to use for the zoom-out button. * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|undefined} [zoomInTipLabel='Zoom in'] Text label to use for the button tip. - * @property {string|undefined} [zoomOutTipLabel='Zoom out'] Text label to use for the button tip. - * @property {number|undefined} [delta=1] The zoom delta applied on each click. - * @property {Element|string|undefined} [target] Specify a target if you want the control to be + * @property {string} [zoomInTipLabel='Zoom in'] Text label to use for the button tip. + * @property {string} [zoomOutTipLabel='Zoom out'] Text label to use for the button tip. + * @property {number} [delta=1] The zoom delta applied on each click. + * @property {Element|string} [target] Specify a target if you want the control to be * rendered outside of the map's viewport. */ diff --git a/src/ol/control/ZoomSlider.js b/src/ol/control/ZoomSlider.js index 3360cbd8d8..23a1cdbace 100644 --- a/src/ol/control/ZoomSlider.js +++ b/src/ol/control/ZoomSlider.js @@ -27,8 +27,8 @@ const Direction = { /** * @typedef {Object} Options - * @property {string|undefined} className CSS class name. - * @property {number|undefined} [duration=200] Animation duration in milliseconds. + * @property {string} [className='ol-zoomslider'] CSS class name. + * @property {number} [duration=200] Animation duration in milliseconds. * @property {number|undefined} maxResolution Maximum resolution. * @property {number|undefined} minResolution Minimum resolution. * @property {function(ol.MapEvent)|undefined} render Function called when the control From 403a7bdfc74587979e7d1500ca7ce16d48de464a Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 13 Mar 2018 13:26:34 +0100 Subject: [PATCH 2/2] Mark optional property with square brackets --- src/ol/control/Attribution.js | 25 +++++++++++-------------- src/ol/control/MousePosition.js | 13 +++++-------- src/ol/control/OverviewMap.js | 28 ++++++++++++---------------- src/ol/control/Rotate.js | 2 +- src/ol/control/ScaleLine.js | 10 +++++----- src/ol/control/ZoomSlider.js | 2 +- src/ol/control/ZoomToExtent.js | 13 ++++++------- 7 files changed, 41 insertions(+), 52 deletions(-) diff --git a/src/ol/control/Attribution.js b/src/ol/control/Attribution.js index 27aed85ccd..b72d1a8dce 100644 --- a/src/ol/control/Attribution.js +++ b/src/ol/control/Attribution.js @@ -13,26 +13,23 @@ import {visibleAtResolution} from '../layer/Layer.js'; /** * @typedef {Object} Options - * @property {string|undefined} className CSS class name. Default is - * `'ol-attribution'`. - * @property {Element|string|undefined} target Specify a target if you + * @property {string} [className='ol-attribution'] CSS class name. + * @property {Element|string} [target] Specify a target if you * want the control to be rendered outside of the map's * viewport. - * @property {boolean|undefined} collapsible Specify if attributions can + * @property {boolean} [collapsible=true] Specify if attributions can * be collapsed. If you use an OSM source, should be set to `false` — see * {@link https://www.openstreetmap.org/copyright OSM Copyright} — - * Default is `true`. - * @property {boolean|undefined} collapsed Specify if attributions should - * be collapsed at startup. Default is `true`. - * @property {string|undefined} tipLabel Text label to use for the button - * tip. Default is `'Attributions'` - * @property {string|Element|undefined} label Text label to use for the - * collapsed attributions button. Default is `'i'`. + * @property {boolean} [collapsed=true] Specify if attributions should + * be collapsed at startup. + * @property {string} [tipLabel='Attributions'] Text label to use for the button tip. + * @property {string} [label='i'] Text label to use for the + * collapsed attributions button. * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|Element|undefined} collapseLabel Text label to use - * for the expanded attributions button. Default is `'»'`. + * @property {string|Element} [collapseLabel='»'] Text label to use + * for the expanded attributions button. * Instead of text, also an element (e.g. a `span` element) can be used. - * @property {function(ol.MapEvent)|undefined} render Function called when + * @property {function(ol.MapEvent)} [render] Function called when * the control should be re-rendered. This is called in a `requestAnimationFrame` * callback. */ diff --git a/src/ol/control/MousePosition.js b/src/ol/control/MousePosition.js index 43a4c30cb1..22f2b884c3 100644 --- a/src/ol/control/MousePosition.js +++ b/src/ol/control/MousePosition.js @@ -23,18 +23,15 @@ const COORDINATE_FORMAT = 'coordinateFormat'; /** * @typedef {Object} Options - * @property {string|undefined} className CSS class name. Default is - * `'ol-mouse-position'`. - * @property {module:ol/coordinate~CoordinateFormat|undefined} coordinateFormat - * Coordinate format. + * @property {string} [className='ol-mouse-position'] CSS class name. + * @property {module:ol/coordinate~CoordinateFormat} [coordinateFormat] Coordinate format. * @property {ol.ProjectionLike} projection Projection. - * @property {function(ol.MapEvent)|undefined} render Function called when the + * @property {function(ol.MapEvent)} [render] Function called when the * control should be re-rendered. This is called in a `requestAnimationFrame` * callback. - * @property {Element|string|undefined} target Specify a target if you want the + * @property {Element|string} [target] Specify a target if you want the * control to be rendered outside of the map's viewport. - * @property {string|undefined} undefinedHTML Markup for undefined coordinates. - * Default is `''` (empty string). + * @property {string} [undefinedHTML=''] Markup for undefined coordinates. */ diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index 382a394a6b..f2914d8eb5 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -38,26 +38,22 @@ const MIN_RATIO = 0.1; /** * @typedef {Object} Options - * @property {boolean|undefined} collapsed Whether the control should start collapsed - * or not (expanded). Default to `true`. - * @property {string|Element|undefined} collapseLabel Text label to use for the - * expanded overviewmap button. Default is `'«'`. Instead of text, also an element - * (e.g. a `span` element) can be used. - * @property {boolean|undefined} collapsible Whether the control can be collapsed - * or not. Default to `true`. - * @property {string|Element|undefined} label Text label to use for the collapsed - * overviewmap button. Default is `'»'`. Instead of text, also an element - * (e.g. a `span` element) can be used. - * @property {Array.|ol.Collection.|undefined} layers + * @property {boolean} [collapsed=true] Whether the control should start collapsed + * or not (expanded). + * @property {string|Element} [collapseLabel='«'] Text label to use for the + * expanded overviewmap button. Instead of text, also an element (e.g. a `span` element) can be used. + * @property {boolean} [collapsible=true] Whether the control can be collapsed or not. + * @property {string|Element} [label='»'] Text label to use for the collapsed + * overviewmap button. Instead of text, also an element (e.g. a `span` element) can be used. + * @property {Array.|ol.Collection.} [layers] * Layers for the overview map. If not set, then all main map layers are used * instead. - * @property {function(ol.MapEvent)|undefined} render Function called when the control + * @property {function(ol.MapEvent)} [render] Function called when the control * should be re-rendered. This is called in a `requestAnimationFrame` callback. - * @property {Element|string|undefined} target Specify a target if you want the control + * @property {Element|string} [target] Specify a target if you want the control * to be rendered outside of the map's viewport. - * @property {string|undefined} tipLabel Text label to use for the button tip. Default - * is `'Overview map'`. - * @property {ol.View|undefined} view Custom view for the overview map. If not provided, + * @property {string} [tipLabel='Overview map'] Text label to use for the button tip. + * @property {ol.View} [view] Custom view for the overview map. If not provided, * a default view with an EPSG:3857 projection will be used. */ diff --git a/src/ol/control/Rotate.js b/src/ol/control/Rotate.js index 0ff894b973..6c3d7f1cd3 100644 --- a/src/ol/control/Rotate.js +++ b/src/ol/control/Rotate.js @@ -18,7 +18,7 @@ import {inherits} from '../index.js'; * @property {string} [tipLabel='Reset rotation'] Text label to use for the rotate tip. * @property {number} [duration=250] Animation duration in milliseconds. * @property {boolean} [autoHide=true] Hide the control when rotation is 0. - * @property {function(ol.MapEvent)|undefined} render Function called when the control should + * @property {function(ol.MapEvent)} [render] Function called when the control should * be re-rendered. This is called in a `requestAnimationFrame` callback. * @property {function()} [resetNorth] Function called when the control is clicked. * This will override the default `resetNorth`. diff --git a/src/ol/control/ScaleLine.js b/src/ol/control/ScaleLine.js index 3de1e823f5..d3b6b2fb42 100644 --- a/src/ol/control/ScaleLine.js +++ b/src/ol/control/ScaleLine.js @@ -27,13 +27,13 @@ const LEADING_DIGITS = [1, 2, 5]; /** * @typedef {Object} Options - * @property {string|undefined} className CSS Class name. Default is `'ol-scale-line'`. - * @property {number|undefined} minWidth Minimum width in pixels. Default is `64`. - * @property {function(ol.MapEvent)|undefined} render Function called when the control + * @property {string} [className='ol-scale-line'] CSS Class name. + * @property {number} [minWidth=64] Minimum width in pixels. + * @property {function(ol.MapEvent)} [render] Function called when the control * should be re-rendered. This is called in a `requestAnimationFrame` callback. - * @property {Element|string|undefined} target Specify a target if you want the control + * @property {Element|string} [target] Specify a target if you want the control * to be rendered outside of the map's viewport. - * @property {ol.control.ScaleLineUnits|string|undefined} units Units. Default is `'metric'`. + * @property {ol.control.ScaleLineUnits|string} [units='metric'] Units. */ diff --git a/src/ol/control/ZoomSlider.js b/src/ol/control/ZoomSlider.js index 23a1cdbace..8717cc22d8 100644 --- a/src/ol/control/ZoomSlider.js +++ b/src/ol/control/ZoomSlider.js @@ -31,7 +31,7 @@ const Direction = { * @property {number} [duration=200] Animation duration in milliseconds. * @property {number|undefined} maxResolution Maximum resolution. * @property {number|undefined} minResolution Minimum resolution. - * @property {function(ol.MapEvent)|undefined} render Function called when the control + * @property {function(ol.MapEvent)} [render] Function called when the control * should be re-rendered. This is called in a `requestAnimationFrame` callback. */ diff --git a/src/ol/control/ZoomToExtent.js b/src/ol/control/ZoomToExtent.js index b32f05b50a..30563f7fa7 100644 --- a/src/ol/control/ZoomToExtent.js +++ b/src/ol/control/ZoomToExtent.js @@ -10,14 +10,13 @@ import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js'; /** * @typedef {Object} Options - * @property {string|undefined} className Class name. Default is `'ol-zoom-extent'`. - * @property {Element|string|undefined} target Specify a target if you want the control + * @property {string} [className='ol-zoom-extent'] Class name. + * @property {Element|string} [target] Specify a target if you want the control * to be rendered outside of the map's viewport. - * @property {string|Element|undefined} label Text label to use for the button. Default - * is `'E'`. Instead of text, also an element (e.g. a `span` element) can be used. - * @property {string|undefined} tipLabel Text label to use for the button tip. Default - * is `'Zoom to extent'`. - * @property {ol.Extent|undefined} extent The extent to zoom to. If undefined the validity + * @property {string|Element} [label='E'] Text label to use for the button. + * Instead of text, also an element (e.g. a `span` element) can be used. + * @property {string} [tipLabel='Zoom to extent'] Text label to use for the button tip. + * @property {ol.Extent} [extent] The extent to zoom to. If undefined the validity * extent of the view projection is used. */