Fix type check errors in ol/render/canvas/Immediate

This commit is contained in:
Kevin Schmidt
2018-10-02 12:32:37 -06:00
parent 023ad3c531
commit 452d5454cb

View File

@@ -577,7 +577,7 @@ class CanvasImmediateRenderer extends VectorContext {
const context = this.context_; const context = this.context_;
const flatCoordinates = geometry.getFlatCoordinates(); const flatCoordinates = geometry.getFlatCoordinates();
let offset = 0; let offset = 0;
const ends = geometry.getEnds(); const ends = /** @type {Array<number>} */ (geometry.getEnds());
const stride = geometry.getStride(); const stride = geometry.getStride();
context.beginPath(); context.beginPath();
for (let i = 0, ii = ends.length; i < ii; ++i) { for (let i = 0, ii = ends.length; i < ii; ++i) {
@@ -612,7 +612,7 @@ class CanvasImmediateRenderer extends VectorContext {
const context = this.context_; const context = this.context_;
context.beginPath(); context.beginPath();
this.drawRings_(geometry.getOrientedFlatCoordinates(), this.drawRings_(geometry.getOrientedFlatCoordinates(),
0, geometry.getEnds(), geometry.getStride()); 0, /** @type {Array<number>} */ (geometry.getEnds()), geometry.getStride());
if (this.fillState_) { if (this.fillState_) {
context.fill(); context.fill();
} }
@@ -693,12 +693,12 @@ class CanvasImmediateRenderer extends VectorContext {
const context = this.context_; const context = this.context_;
const contextStrokeState = this.contextStrokeState_; const contextStrokeState = this.contextStrokeState_;
if (!contextStrokeState) { if (!contextStrokeState) {
context.lineCap = strokeState.lineCap; context.lineCap = /** @type {CanvasLineCap} */ (strokeState.lineCap);
if (CANVAS_LINE_DASH) { if (CANVAS_LINE_DASH) {
context.setLineDash(strokeState.lineDash); context.setLineDash(strokeState.lineDash);
context.lineDashOffset = strokeState.lineDashOffset; context.lineDashOffset = strokeState.lineDashOffset;
} }
context.lineJoin = strokeState.lineJoin; context.lineJoin = /** @type {CanvasLineJoin} */ (strokeState.lineJoin);
context.lineWidth = strokeState.lineWidth; context.lineWidth = strokeState.lineWidth;
context.miterLimit = strokeState.miterLimit; context.miterLimit = strokeState.miterLimit;
context.strokeStyle = strokeState.strokeStyle; context.strokeStyle = strokeState.strokeStyle;
@@ -713,7 +713,7 @@ class CanvasImmediateRenderer extends VectorContext {
}; };
} else { } else {
if (contextStrokeState.lineCap != strokeState.lineCap) { if (contextStrokeState.lineCap != strokeState.lineCap) {
contextStrokeState.lineCap = context.lineCap = strokeState.lineCap; contextStrokeState.lineCap = context.lineCap = /** @type {CanvasLineCap} */ (strokeState.lineCap);
} }
if (CANVAS_LINE_DASH) { if (CANVAS_LINE_DASH) {
if (!equals(contextStrokeState.lineDash, strokeState.lineDash)) { if (!equals(contextStrokeState.lineDash, strokeState.lineDash)) {
@@ -725,7 +725,7 @@ class CanvasImmediateRenderer extends VectorContext {
} }
} }
if (contextStrokeState.lineJoin != strokeState.lineJoin) { if (contextStrokeState.lineJoin != strokeState.lineJoin) {
contextStrokeState.lineJoin = context.lineJoin = strokeState.lineJoin; contextStrokeState.lineJoin = context.lineJoin = /** @type {CanvasLineJoin} */ (strokeState.lineJoin);
} }
if (contextStrokeState.lineWidth != strokeState.lineWidth) { if (contextStrokeState.lineWidth != strokeState.lineWidth) {
contextStrokeState.lineWidth = context.lineWidth = strokeState.lineWidth; contextStrokeState.lineWidth = context.lineWidth = strokeState.lineWidth;
@@ -752,8 +752,8 @@ class CanvasImmediateRenderer extends VectorContext {
textState.textAlign : defaultTextAlign; textState.textAlign : defaultTextAlign;
if (!contextTextState) { if (!contextTextState) {
context.font = textState.font; context.font = textState.font;
context.textAlign = textAlign; context.textAlign = /** @type {CanvasTextAlign} */ (textAlign);
context.textBaseline = textState.textBaseline; context.textBaseline = /** @type {CanvasTextBaseline} */ (textState.textBaseline);
this.contextTextState_ = { this.contextTextState_ = {
font: textState.font, font: textState.font,
textAlign: textAlign, textAlign: textAlign,
@@ -764,11 +764,11 @@ class CanvasImmediateRenderer extends VectorContext {
contextTextState.font = context.font = textState.font; contextTextState.font = context.font = textState.font;
} }
if (contextTextState.textAlign != textAlign) { if (contextTextState.textAlign != textAlign) {
contextTextState.textAlign = context.textAlign = textAlign; contextTextState.textAlign = context.textAlign = /** @type {CanvasTextAlign} */ (textAlign);
} }
if (contextTextState.textBaseline != textState.textBaseline) { if (contextTextState.textBaseline != textState.textBaseline) {
contextTextState.textBaseline = context.textBaseline = contextTextState.textBaseline = context.textBaseline =
textState.textBaseline; /** @type {CanvasTextBaseline} */ (textState.textBaseline);
} }
} }
} }