Merge pull request #8869 from ahocevar/typescript-fixes

Fix more types for TypeScript
This commit is contained in:
Andreas Hocevar
2018-10-31 12:07:28 +01:00
committed by GitHub
6 changed files with 26 additions and 21 deletions

View File

@@ -177,7 +177,7 @@ class Attribution extends Control {
continue;
}
const source = layerState.layer.getSource();
const source = /** @type {import("../layer/Layer.js").default} */ (layerState.layer).getSource();
if (!source) {
continue;
}

View File

@@ -63,10 +63,7 @@ class BaseLayer extends BaseObject {
* @type {import("./Layer.js").State}
* @private
*/
this.state_ = /** @type {import("./Layer.js").State} */ ({
layer: /** @type {import("./Layer.js").default} */ (this),
managed: true
});
this.state_ = null;
/**
* The layer type.
@@ -89,15 +86,21 @@ class BaseLayer extends BaseObject {
* @return {import("./Layer.js").State} Layer state.
*/
getLayerState() {
this.state_.opacity = clamp(this.getOpacity(), 0, 1);
this.state_.sourceState = this.getSourceState();
this.state_.visible = this.getVisible();
this.state_.extent = this.getExtent();
this.state_.zIndex = this.getZIndex() || 0;
this.state_.maxResolution = this.getMaxResolution();
this.state_.minResolution = Math.max(this.getMinResolution(), 0);
/** @type {import("./Layer.js").State} */
const state = this.state_ || /** @type {?} */ ({
layer: this,
managed: true
});
state.opacity = clamp(this.getOpacity(), 0, 1);
state.sourceState = this.getSourceState();
state.visible = this.getVisible();
state.extent = this.getExtent();
state.zIndex = this.getZIndex() || 0;
state.maxResolution = this.getMaxResolution();
state.minResolution = Math.max(this.getMinResolution(), 0);
this.state_ = state;
return this.state_;
return state;
}
/**

View File

@@ -35,7 +35,7 @@ import SourceState from '../source/State.js';
/**
* @typedef {Object} State
* @property {import("./Layer.js").default} layer
* @property {import("./Base.js").default} layer
* @property {number} opacity
* @property {SourceState} sourceState
* @property {boolean} visible

View File

@@ -721,7 +721,8 @@ class CanvasReplay extends VectorContext {
const pathLength = lineStringLength(pixelCoordinates, begin, end, 2);
const textLength = measure(text);
if (overflow || textLength <= pathLength) {
const textReplay = /** @type {import("./TextReplay.js").default} */ (this);
/** @type {import("./TextReplay.js").default} */
const textReplay = /** @type {?} */ (this);
const textAlign = textReplay.textStates[textKey].textAlign;
const startM = (pathLength - textLength) * TEXT_ALIGN[textAlign];
const parts = drawTextOnPath(

View File

@@ -154,9 +154,10 @@ class MapRenderer extends Disposable {
const layer = layerState.layer;
if (visibleAtResolution(layerState, viewResolution) && layerFilter.call(thisArg2, layer)) {
const layerRenderer = this.getLayerRenderer(layer);
if (layer.getSource()) {
const source = /** @type {import("../layer/Layer.js").default} */ (layer).getSource();
if (source) {
result = layerRenderer.forEachFeatureAtCoordinate(
layer.getSource().getWrapX() ? translatedCoordinate : coordinate,
source.getWrapX() ? translatedCoordinate : coordinate,
frameState, hitTolerance, forEachFeatureAtCoordinate);
}
if (result) {
@@ -207,7 +208,7 @@ class MapRenderer extends Disposable {
}
/**
* @param {import("../layer/Layer.js").default} layer Layer.
* @param {import("../layer/Base.js").default} layer Layer.
* @protected
* @return {import("./Layer.js").default} Layer renderer.
*/

View File

@@ -180,11 +180,11 @@ class CanvasImageLayerRenderer extends IntermediateCanvasRenderer {
/**
* @inheritDoc
*/
forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback, thisArg) {
forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback) {
if (this.vectorRenderer_) {
return this.vectorRenderer_.forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback, thisArg);
return this.vectorRenderer_.forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback);
} else {
return super.forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback, thisArg);
return super.forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback);
}
}
}