Merge pull request #8724 from fredj/ts_fixes

Typescript misc fixes
This commit is contained in:
Frédéric Junod
2018-09-27 10:47:57 +02:00
committed by GitHub
19 changed files with 46 additions and 47 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ When rendering with the Immediate API, symbols will no longer be snapped to inte
#### Geometry constructor and `setCoordinates` no longer accept `null` coordinates #### Geometry constructor and `setCoordinates` no longer accept `null` coordinates
Geometries (`ol/geom/*`) now need to be constructed with valid coordinates (center for `ol/geom/Circle`) as first constructor argument. The same applies to the `setCoordinates()` (`setCenter() for `ol/geom/Circle`) method. Geometries (`ol/geom/*`) now need to be constructed with valid coordinates (center for `ol/geom/Circle`) as first constructor argument. The same applies to the `setCoordinates()` (`setCenter()` for `ol/geom/Circle`) method.
### v5.0.0 ### v5.0.0
+21 -21
View File
@@ -300,7 +300,7 @@ function readGeometry(object, opt_options) {
/** /**
* @param {GeoJSONGeometryCollection} object Object. * @param {GeoJSONGeometryCollection} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options. * @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @return {import("../geom/GeometryCollection.js").default} Geometry collection. * @return {GeometryCollection} Geometry collection.
*/ */
function readGeometryCollectionGeometry(object, opt_options) { function readGeometryCollectionGeometry(object, opt_options) {
const geometries = object['geometries'].map( const geometries = object['geometries'].map(
@@ -317,7 +317,7 @@ function readGeometryCollectionGeometry(object, opt_options) {
/** /**
* @param {GeoJSONPoint} object Object. * @param {GeoJSONPoint} object Object.
* @return {import("../geom/Point.js").default} Point. * @return {Point} Point.
*/ */
function readPointGeometry(object) { function readPointGeometry(object) {
return new Point(object['coordinates']); return new Point(object['coordinates']);
@@ -326,7 +326,7 @@ function readPointGeometry(object) {
/** /**
* @param {GeoJSONLineString} object Object. * @param {GeoJSONLineString} object Object.
* @return {import("../geom/LineString.js").default} LineString. * @return {LineString} LineString.
*/ */
function readLineStringGeometry(object) { function readLineStringGeometry(object) {
return new LineString(object['coordinates']); return new LineString(object['coordinates']);
@@ -335,7 +335,7 @@ function readLineStringGeometry(object) {
/** /**
* @param {GeoJSONMultiLineString} object Object. * @param {GeoJSONMultiLineString} object Object.
* @return {import("../geom/MultiLineString.js").default} MultiLineString. * @return {MultiLineString} MultiLineString.
*/ */
function readMultiLineStringGeometry(object) { function readMultiLineStringGeometry(object) {
return new MultiLineString(object['coordinates']); return new MultiLineString(object['coordinates']);
@@ -344,7 +344,7 @@ function readMultiLineStringGeometry(object) {
/** /**
* @param {GeoJSONMultiPoint} object Object. * @param {GeoJSONMultiPoint} object Object.
* @return {import("../geom/MultiPoint.js").default} MultiPoint. * @return {MultiPoint} MultiPoint.
*/ */
function readMultiPointGeometry(object) { function readMultiPointGeometry(object) {
return new MultiPoint(object['coordinates']); return new MultiPoint(object['coordinates']);
@@ -353,7 +353,7 @@ function readMultiPointGeometry(object) {
/** /**
* @param {GeoJSONMultiPolygon} object Object. * @param {GeoJSONMultiPolygon} object Object.
* @return {import("../geom/MultiPolygon.js").default} MultiPolygon. * @return {MultiPolygon} MultiPolygon.
*/ */
function readMultiPolygonGeometry(object) { function readMultiPolygonGeometry(object) {
return new MultiPolygon(object['coordinates']); return new MultiPolygon(object['coordinates']);
@@ -362,7 +362,7 @@ function readMultiPolygonGeometry(object) {
/** /**
* @param {GeoJSONPolygon} object Object. * @param {GeoJSONPolygon} object Object.
* @return {import("../geom/Polygon.js").default} Polygon. * @return {Polygon} Polygon.
*/ */
function readPolygonGeometry(object) { function readPolygonGeometry(object) {
return new Polygon(object['coordinates']); return new Polygon(object['coordinates']);
@@ -382,31 +382,31 @@ function writeGeometry(geometry, opt_options) {
let geoJSON; let geoJSON;
switch (type) { switch (type) {
case GeometryType.POINT: { case GeometryType.POINT: {
geoJSON = writePointGeometry(/** @type {import("../geom/Point.js").default} */ (geometry), opt_options); geoJSON = writePointGeometry(/** @type {Point} */ (geometry), opt_options);
break; break;
} }
case GeometryType.LINE_STRING: { case GeometryType.LINE_STRING: {
geoJSON = writeLineStringGeometry(/** @type {import("../geom/LineString.js").default} */ (geometry), opt_options); geoJSON = writeLineStringGeometry(/** @type {LineString} */ (geometry), opt_options);
break; break;
} }
case GeometryType.POLYGON: { case GeometryType.POLYGON: {
geoJSON = writePolygonGeometry(/** @type {import("../geom/Polygon.js").default} */ (geometry), opt_options); geoJSON = writePolygonGeometry(/** @type {Polygon} */ (geometry), opt_options);
break; break;
} }
case GeometryType.MULTI_POINT: { case GeometryType.MULTI_POINT: {
geoJSON = writeMultiPointGeometry(/** @type {import("../geom/MultiPoint.js").default} */ (geometry), opt_options); geoJSON = writeMultiPointGeometry(/** @type {MultiPoint} */ (geometry), opt_options);
break; break;
} }
case GeometryType.MULTI_LINE_STRING: { case GeometryType.MULTI_LINE_STRING: {
geoJSON = writeMultiLineStringGeometry(/** @type {import("../geom/MultiLineString.js").default} */ (geometry), opt_options); geoJSON = writeMultiLineStringGeometry(/** @type {MultiLineString} */ (geometry), opt_options);
break; break;
} }
case GeometryType.MULTI_POLYGON: { case GeometryType.MULTI_POLYGON: {
geoJSON = writeMultiPolygonGeometry(/** @type {import("../geom/MultiPolygon.js").default} */ (geometry), opt_options); geoJSON = writeMultiPolygonGeometry(/** @type {MultiPolygon} */ (geometry), opt_options);
break; break;
} }
case GeometryType.GEOMETRY_COLLECTION: { case GeometryType.GEOMETRY_COLLECTION: {
geoJSON = writeGeometryCollectionGeometry(/** @type {import("../geom/GeometryCollection.js").default} */ (geometry), opt_options); geoJSON = writeGeometryCollectionGeometry(/** @type {GeometryCollection} */ (geometry), opt_options);
break; break;
} }
case GeometryType.CIRCLE: { case GeometryType.CIRCLE: {
@@ -425,7 +425,7 @@ function writeGeometry(geometry, opt_options) {
/** /**
* @param {import("../geom/GeometryCollection.js").default} geometry Geometry. * @param {GeometryCollection} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection. * @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
*/ */
@@ -443,7 +443,7 @@ function writeGeometryCollectionGeometry(geometry, opt_options) {
/** /**
* @param {import("../geom/LineString.js").default} geometry Geometry. * @param {LineString} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {GeoJSONGeometry} GeoJSON geometry. * @return {GeoJSONGeometry} GeoJSON geometry.
*/ */
@@ -456,7 +456,7 @@ function writeLineStringGeometry(geometry, opt_options) {
/** /**
* @param {import("../geom/MultiLineString.js").default} geometry Geometry. * @param {MultiLineString} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {GeoJSONGeometry} GeoJSON geometry. * @return {GeoJSONGeometry} GeoJSON geometry.
*/ */
@@ -469,7 +469,7 @@ function writeMultiLineStringGeometry(geometry, opt_options) {
/** /**
* @param {import("../geom/MultiPoint.js").default} geometry Geometry. * @param {MultiPoint} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {GeoJSONGeometry} GeoJSON geometry. * @return {GeoJSONGeometry} GeoJSON geometry.
*/ */
@@ -482,7 +482,7 @@ function writeMultiPointGeometry(geometry, opt_options) {
/** /**
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry. * @param {MultiPolygon} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {GeoJSONGeometry} GeoJSON geometry. * @return {GeoJSONGeometry} GeoJSON geometry.
*/ */
@@ -499,7 +499,7 @@ function writeMultiPolygonGeometry(geometry, opt_options) {
/** /**
* @param {import("../geom/Point.js").default} geometry Geometry. * @param {Point} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {GeoJSONGeometry} GeoJSON geometry. * @return {GeoJSONGeometry} GeoJSON geometry.
*/ */
@@ -512,7 +512,7 @@ function writePointGeometry(geometry, opt_options) {
/** /**
* @param {import("../geom/Polygon.js").default} geometry Geometry. * @param {Polygon} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {GeoJSONGeometry} GeoJSON geometry. * @return {GeoJSONGeometry} GeoJSON geometry.
*/ */
+3 -3
View File
@@ -23,7 +23,7 @@ const tmpTransform = createTransform();
* structure, optimized for vector tile rendering and styling. Geometry access * structure, optimized for vector tile rendering and styling. Geometry access
* through the API is limited to getting the type and extent of the geometry. * through the API is limited to getting the type and extent of the geometry.
* *
* @param {import("../geom/GeometryType.js").default} type Geometry type. * @param {GeometryType} type Geometry type.
* @param {Array<number>} flatCoordinates Flat coordinates. These always need * @param {Array<number>} flatCoordinates Flat coordinates. These always need
* to be right-handed for polygons. * to be right-handed for polygons.
* @param {Array<number>|Array<Array<number>>} ends Ends or Endss. * @param {Array<number>|Array<Array<number>>} ends Ends or Endss.
@@ -46,7 +46,7 @@ class RenderFeature {
/** /**
* @private * @private
* @type {import("../geom/GeometryType.js").default} * @type {GeometryType}
*/ */
this.type_ = type; this.type_ = type;
@@ -216,7 +216,7 @@ class RenderFeature {
/** /**
* Get the type of this feature's geometry. * Get the type of this feature's geometry.
* @return {import("../geom/GeometryType.js").default} Geometry type. * @return {GeometryType} Geometry type.
* @api * @api
*/ */
getType() { getType() {
+1 -1
View File
@@ -6,7 +6,7 @@ import ReplayType from '../render/ReplayType.js';
/** /**
* @const * @const
* @type {Array<import("./ReplayType.js").default>} * @type {Array<ReplayType>}
*/ */
export const ORDER = [ export const ORDER = [
ReplayType.POLYGON, ReplayType.POLYGON,
+1 -1
View File
@@ -94,7 +94,7 @@ const TOS_ATTRIBUTION = '<a class="ol-attribution-bing-tos" ' +
*/ */
class BingMaps extends TileImage { class BingMaps extends TileImage {
/** /**
* @param {Options=} options Bing Maps options. * @param {Options} options Bing Maps options.
*/ */
constructor(options) { constructor(options) {
+1 -1
View File
@@ -44,7 +44,7 @@ import XYZ from '../source/XYZ.js';
*/ */
class CartoDB extends XYZ { class CartoDB extends XYZ {
/** /**
* @param {Options=} options CartoDB options. * @param {Options} options CartoDB options.
*/ */
constructor(options) { constructor(options) {
super({ super({
+1 -1
View File
@@ -41,7 +41,7 @@ import {appendParams} from '../uri.js';
*/ */
class ImageMapGuide extends ImageSource { class ImageMapGuide extends ImageSource {
/** /**
* @param {Options=} options ImageMapGuide options. * @param {Options} options ImageMapGuide options.
*/ */
constructor(options) { constructor(options) {
+1 -1
View File
@@ -35,7 +35,7 @@ import ImageSource, {defaultImageLoadFunction} from '../source/Image.js';
*/ */
class Static extends ImageSource { class Static extends ImageSource {
/** /**
* @param {Options=} options ImageStatic options. * @param {Options} options ImageStatic options.
*/ */
constructor(options) { constructor(options) {
const crossOrigin = options.crossOrigin !== undefined ? const crossOrigin = options.crossOrigin !== undefined ?
+1 -1
View File
@@ -144,7 +144,7 @@ class RasterSourceEvent extends Event {
*/ */
class RasterSource extends ImageSource { class RasterSource extends ImageSource {
/** /**
* @param {Options=} options Options. * @param {Options} options Options.
*/ */
constructor(options) { constructor(options) {
super({}); super({});
+2 -3
View File
@@ -91,10 +91,9 @@ const ProviderConfig = {
/** /**
* @typedef {Object} Options * @typedef {Object} Options
* @property {number} [cacheSize=2048] Cache size. * @property {number} [cacheSize=2048] Cache size.
* @property {string} [layer] Layer. * @property {string} layer Layer name.
* @property {number} [minZoom] Minimum zoom. * @property {number} [minZoom] Minimum zoom.
* @property {number} [maxZoom] Maximum zoom. * @property {number} [maxZoom] Maximum zoom.
* @property {boolean} [opaque] Whether the layer is opaque.
* @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("../Tile.js").LoadFunction} [tileLoadFunction] * @property {import("../Tile.js").LoadFunction} [tileLoadFunction]
@@ -116,7 +115,7 @@ const ProviderConfig = {
*/ */
class Stamen extends XYZ { class Stamen extends XYZ {
/** /**
* @param {Options=} options Stamen options. * @param {Options} options Stamen options.
*/ */
constructor(options) { constructor(options) {
const i = options.layer.indexOf('-'); const i = options.layer.indexOf('-');
+1 -1
View File
@@ -35,7 +35,7 @@ import {wrapX, getForProjection as getTileGridForProjection} from '../tilegrid.j
*/ */
class TileSource extends Source { class TileSource extends Source {
/** /**
* @param {Options=} options SourceTile source options. * @param {Options} options SourceTile source options.
*/ */
constructor(options) { constructor(options) {
+1 -1
View File
@@ -91,7 +91,7 @@ class LabeledTile extends Tile {
*/ */
class TileDebug extends TileSource { class TileDebug extends TileSource {
/** /**
* @param {Options=} options Debug tile options. * @param {Options} options Debug tile options.
*/ */
constructor(options) { constructor(options) {
+3 -3
View File
@@ -95,7 +95,7 @@ class TileImage extends UrlTile {
/** /**
* @protected * @protected
* @type {function(new: import("../ImageTile.js").default, import("../tilecoord.js").TileCoord, import("../TileState.js").default, string, * @type {function(new: ImageTile, import("../tilecoord.js").TileCoord, TileState, string,
* ?string, import("../Tile.js").LoadFunction, import("../Tile.js").Options=)} * ?string, import("../Tile.js").LoadFunction, import("../Tile.js").Options=)}
*/ */
this.tileClass = options.tileClass !== undefined ? this.tileClass = options.tileClass !== undefined ?
@@ -103,7 +103,7 @@ class TileImage extends UrlTile {
/** /**
* @protected * @protected
* @type {!Object<string, import("../TileCache.js").default>} * @type {!Object<string, TileCache>}
*/ */
this.tileCacheForProjection = {}; this.tileCacheForProjection = {};
@@ -391,7 +391,7 @@ class TileImage extends UrlTile {
/** /**
* @param {import("../ImageTile.js").default} imageTile Image tile. * @param {ImageTile} imageTile Image tile.
* @param {string} src Source. * @param {string} src Source.
*/ */
function defaultTileLoadFunction(imageTile, src) { function defaultTileLoadFunction(imageTile, src) {
+1 -1
View File
@@ -70,7 +70,7 @@ import {createXYZ, extentFromProjection} from '../tilegrid.js';
*/ */
class TileJSON extends TileImage { class TileJSON extends TileImage {
/** /**
* @param {Options=} options TileJSON options. * @param {Options} options TileJSON options.
*/ */
constructor(options) { constructor(options) {
super({ super({
+2 -2
View File
@@ -28,7 +28,7 @@ export class CustomTile extends Tile {
/** /**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../TileState.js").default} state State. * @param {TileState} state State.
* @param {string} src Image source URI. * @param {string} src Image source URI.
* @param {import("../extent.js").Extent} extent Extent of the tile. * @param {import("../extent.js").Extent} extent Extent of the tile.
* @param {boolean} preemptive Load the tile when visible (before it's needed). * @param {boolean} preemptive Load the tile when visible (before it's needed).
@@ -279,7 +279,7 @@ export class CustomTile extends Tile {
*/ */
class UTFGrid extends TileSource { class UTFGrid extends TileSource {
/** /**
* @param {Options=} options Source options. * @param {Options} options Source options.
*/ */
constructor(options) { constructor(options) {
super({ super({
+1 -1
View File
@@ -35,7 +35,7 @@ import {getKeyZXY} from '../tilecoord.js';
*/ */
class UrlTile extends TileSource { class UrlTile extends TileSource {
/** /**
* @param {Options=} options Image tile options. * @param {Options} options Image tile options.
*/ */
constructor(options) { constructor(options) {
+2 -2
View File
@@ -112,7 +112,7 @@ class VectorTile extends UrlTile {
/** /**
* @private * @private
* @type {Object<string, import("../VectorTile.js").default>} * @type {Object<string, Tile>}
*/ */
this.sourceTiles_ = {}; this.sourceTiles_ = {};
@@ -124,7 +124,7 @@ class VectorTile extends UrlTile {
/** /**
* @protected * @protected
* @type {function(new: import("../VectorTile.js").default, import("../tilecoord.js").TileCoord, import("../TileState.js").default, string, * @type {function(new: Tile, import("../tilecoord.js").TileCoord, TileState, string,
* import("../format/Feature.js").default, import("../Tile.js").LoadFunction)} * import("../format/Feature.js").default, import("../Tile.js").LoadFunction)}
*/ */
this.tileClass = options.tileClass ? options.tileClass : Tile; this.tileClass = options.tileClass ? options.tileClass : Tile;
+1 -1
View File
@@ -63,7 +63,7 @@ import {appendParams} from '../uri.js';
*/ */
class WMTS extends TileImage { class WMTS extends TileImage {
/** /**
* @param {Options=} options WMTS options. * @param {Options} options WMTS options.
*/ */
constructor(options) { constructor(options) {
+1 -1
View File
@@ -28,7 +28,7 @@ export class CustomTile extends ImageTile {
/** /**
* @param {import("../tilegrid/TileGrid.js").default} tileGrid TileGrid that the tile belongs to. * @param {import("../tilegrid/TileGrid.js").default} tileGrid TileGrid that the tile belongs to.
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../TileState.js").default} state State. * @param {TileState} state State.
* @param {string} src Image source URI. * @param {string} src Image source URI.
* @param {?string} crossOrigin Cross origin. * @param {?string} crossOrigin Cross origin.
* @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function. * @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function.