Merge pull request #8757 from schmidtk/ts-typeof-ctor

Use typeof to simplify JSDoc class types
This commit is contained in:
Andreas Hocevar
2018-10-01 18:33:35 +02:00
committed by GitHub
7 changed files with 10 additions and 28 deletions

View File

@@ -7,11 +7,6 @@ import {createCanvasContext2D} from './dom.js';
import {listenOnce, unlistenByKey} from './events.js'; import {listenOnce, unlistenByKey} from './events.js';
import EventType from './events/EventType.js'; import EventType from './events/EventType.js';
/**
* @typedef {function(new: ImageTile, import("./tilecoord.js").TileCoord,
* TileState, string, ?string, import("./Tile.js").LoadFunction)} TileClass
* @api
*/
class ImageTile extends Tile { class ImageTile extends Tile {

View File

@@ -13,7 +13,7 @@ import {get as getProjection} from '../proj.js';
/** /**
* @typedef {Object} Options * @typedef {Object} Options
* @property {Array<function(new: import("../format/Feature.js").default)>} [formatConstructors] Format constructors. * @property {Array<typeof import("../format/Feature.js").default>} [formatConstructors] Format constructors.
* @property {import("../source/Vector.js").default} [source] Optional vector source where features will be added. If a source is provided * @property {import("../source/Vector.js").default} [source] Optional vector source where features will be added. If a source is provided
* all existing features will be removed and new features will be added when * all existing features will be removed and new features will be added when
* they are dropped on the target. If you want to add features to a vector * they are dropped on the target. If you want to add features to a vector
@@ -101,7 +101,7 @@ class DragAndDrop extends Interaction {
/** /**
* @private * @private
* @type {Array<function(new: import("../format/Feature.js").default)>} * @type {Array<typeof import("../format/Feature.js").default>}
*/ */
this.formatConstructors_ = options.formatConstructors ? this.formatConstructors_ = options.formatConstructors ?
options.formatConstructors : []; options.formatConstructors : [];
@@ -150,15 +150,7 @@ class DragAndDrop extends Interaction {
const formatConstructors = this.formatConstructors_; const formatConstructors = this.formatConstructors_;
let features = []; let features = [];
for (let i = 0, ii = formatConstructors.length; i < ii; ++i) { for (let i = 0, ii = formatConstructors.length; i < ii; ++i) {
/** const format = new formatConstructors[i]();
* Avoid "cannot instantiate abstract class" error.
* @type {Function}
*/
const formatConstructor = formatConstructors[i];
/**
* @type {import("../format/Feature.js").default}
*/
const format = new formatConstructor();
features = this.tryReadFeatures_(format, result, { features = this.tryReadFeatures_(format, result, {
featureProjection: projection featureProjection: projection
}); });

View File

@@ -19,9 +19,7 @@ import {create as createTransform, compose as composeTransform} from '../../tran
/** /**
* @type {Object<ReplayType, * @type {Object<ReplayType, typeof CanvasReplay>}
* function(new: CanvasReplay, number, import("../../extent.js").Extent,
* number, number, boolean, Array<import("../canvas.js").DeclutterGroup>)>}
*/ */
const BATCH_CONSTRUCTORS = { const BATCH_CONSTRUCTORS = {
'Circle': CanvasPolygonReplay, 'Circle': CanvasPolygonReplay,

View File

@@ -19,9 +19,7 @@ import WebGLTextReplay from '../webgl/TextReplay.js';
const HIT_DETECTION_SIZE = [1, 1]; const HIT_DETECTION_SIZE = [1, 1];
/** /**
* @type {Object<import("../ReplayType.js").default, * @type {Object<import("../ReplayType.js").default, typeof import("./Replay.js").default>}
* function(new: import("./Replay.js").default, number,
* import("../../extent.js").Extent)>}
*/ */
const BATCH_CONSTRUCTORS = { const BATCH_CONSTRUCTORS = {
'Circle': WebGLCircleReplay, 'Circle': WebGLCircleReplay,

View File

@@ -27,7 +27,7 @@ import {getForProjection as getTileGridForProjection} from '../tilegrid.js';
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels). * @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision. * Higher values can increase reprojection performance, but decrease precision.
* @property {import("./State.js").default} [state] Source state. * @property {import("./State.js").default} [state] Source state.
* @property {import("../ImageTile.js").TileClass} [tileClass] Class used to instantiate image tiles. * @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/ImageTile~ImageTile}. * Default is {@link module:ol/ImageTile~ImageTile}.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid. * @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is * @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
@@ -93,8 +93,7 @@ class TileImage extends UrlTile {
/** /**
* @protected * @protected
* @type {function(new: ImageTile, import("../tilecoord.js").TileCoord, TileState, string, * @type {typeof ImageTile}
* ?string, import("../Tile.js").LoadFunction, import("../Tile.js").Options=)}
*/ */
this.tileClass = options.tileClass !== undefined ? this.tileClass = options.tileClass !== undefined ?
options.tileClass : ImageTile; options.tileClass : ImageTile;

View File

@@ -43,8 +43,8 @@ import {appendParams} from '../uri.js';
* @property {import("../proj.js").ProjectionLike} projection Projection. * @property {import("../proj.js").ProjectionLike} projection Projection.
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels). * @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision. * Higher values can increase reprojection performance, but decrease precision.
* @property {import("../ImageTile.js").TileClass} [tileClass] Class used to instantiate image tiles. * @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/ImageTile~TileClass}. * Default is {@link module:ol/ImageTile~ImageTile}.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid. Base this on the resolutions, * @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid. Base this on the resolutions,
* tilesize and extent supported by the server. * tilesize and extent supported by the server.
* If this is not defined, a default grid will be used: if there is a projection * If this is not defined, a default grid will be used: if there is a projection

View File

@@ -27,7 +27,7 @@ import {appendParams} from '../uri.js';
* @property {import("./WMTSRequestEncoding.js").default|string} [requestEncoding='KVP'] Request encoding. * @property {import("./WMTSRequestEncoding.js").default|string} [requestEncoding='KVP'] Request encoding.
* @property {string} layer Layer name as advertised in the WMTS capabilities. * @property {string} layer Layer name as advertised in the WMTS capabilities.
* @property {string} style Style name as advertised in the WMTS capabilities. * @property {string} style Style name as advertised in the WMTS capabilities.
* @property {import("../ImageTile.js").TileClass} [tileClass] Class used to instantiate image tiles. Default is {@link module:ol/ImageTile~ImageTile}. * @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles. Default is {@link module:ol/ImageTile~ImageTile}.
* @property {number} [tilePixelRatio=1] The pixel ratio used by the tile service. * @property {number} [tilePixelRatio=1] The pixel ratio used by the tile service.
* For example, if the tile service advertizes 256px by 256px tiles but actually sends 512px * For example, if the tile service advertizes 256px by 256px tiles but actually sends 512px
* by 512px images (for retina/hidpi devices) then `tilePixelRatio` * by 512px images (for retina/hidpi devices) then `tilePixelRatio`