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

@@ -13,7 +13,7 @@ import {get as getProjection} from '../proj.js';
/**
* @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
* 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
@@ -101,7 +101,7 @@ class DragAndDrop extends Interaction {
/**
* @private
* @type {Array<function(new: import("../format/Feature.js").default)>}
* @type {Array<typeof import("../format/Feature.js").default>}
*/
this.formatConstructors_ = options.formatConstructors ?
options.formatConstructors : [];
@@ -150,15 +150,7 @@ class DragAndDrop extends Interaction {
const formatConstructors = this.formatConstructors_;
let features = [];
for (let i = 0, ii = formatConstructors.length; i < ii; ++i) {
/**
* Avoid "cannot instantiate abstract class" error.
* @type {Function}
*/
const formatConstructor = formatConstructors[i];
/**
* @type {import("../format/Feature.js").default}
*/
const format = new formatConstructor();
const format = new formatConstructors[i]();
features = this.tryReadFeatures_(format, result, {
featureProjection: projection
});