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; continue;
} }
const source = layerState.layer.getSource(); const source = /** @type {import("../layer/Layer.js").default} */ (layerState.layer).getSource();
if (!source) { if (!source) {
continue; continue;
} }

View File

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

View File

@@ -721,7 +721,8 @@ class CanvasReplay extends VectorContext {
const pathLength = lineStringLength(pixelCoordinates, begin, end, 2); const pathLength = lineStringLength(pixelCoordinates, begin, end, 2);
const textLength = measure(text); const textLength = measure(text);
if (overflow || textLength <= pathLength) { 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 textAlign = textReplay.textStates[textKey].textAlign;
const startM = (pathLength - textLength) * TEXT_ALIGN[textAlign]; const startM = (pathLength - textLength) * TEXT_ALIGN[textAlign];
const parts = drawTextOnPath( const parts = drawTextOnPath(

View File

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

View File

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