Skip to content

Commit

Permalink
chore(TS): Fix some error caused by ts-nocheck removals (#8615)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Jan 22, 2023
1 parent 3cd9f66 commit f850db6
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- chore(TS): Fix some error caused by ts-nocheck removals [#8615](https://github.com/fabricjs/fabric.js/pull/8615)
- refactor(IText): extract draggable text logic to a delegate [#8598](https://github.com/fabricjs/fabric.js/pull/8598)
- chore(TS): Update StaticCanvas to remove ts-nocheck [#8606](https://github.com/fabricjs/fabric.js/pull/8606)
- chore(TS): Update filters to remove ts-nocheck and added types where missing [#8609](https://github.com/fabricjs/fabric.js/pull/8609)
Expand Down
7 changes: 3 additions & 4 deletions src/canvas/canvas_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
CanvasEvents,
DragEventData,
ObjectEvents,
TEvent,
TPointerEvent,
TPointerEventInfo,
TPointerEventNames,
Expand Down Expand Up @@ -1534,14 +1533,14 @@ export class Canvas extends SelectableCanvas {
this._hoveredTargets = this.targets.concat();
if (activeSelection.size() === 1) {
// activate last remaining object
this._setActiveObject(activeSelection.item(0), e);
this._setActiveObject(activeSelection.item(0) as FabricObject, e);
}
} else {
activeSelection.add(target);
this._hoveredTarget = activeSelection;
this._hoveredTargets = this.targets.concat();
}
this._fireSelectionEvents(currentActiveObjects, e);
this._fireSelectionEvents(currentActiveObjects as FabricObject[], e);
}

/**
Expand Down Expand Up @@ -1589,7 +1588,7 @@ export class Canvas extends SelectableCanvas {
* @private
*/
_collectObjects(e: TPointerEvent) {
const group = [],
const group: FabricObject[] = [],
_groupSelector = this._groupSelector,
point1 = new Point(_groupSelector.ex, _groupSelector.ey),
point2 = point1.add(new Point(_groupSelector.left, _groupSelector.top)),
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/static_canvas.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ export class StaticCanvas<
ctx.lineTo(this.width, this.height);
ctx.lineTo(0, this.height);
ctx.closePath();
ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */) : fill;
ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */)! : fill;
if (needsVpt) {
ctx.transform(...v);
}
Expand Down
2 changes: 1 addition & 1 deletion src/filters/colormatrix_filter.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ColorMatrix extends BaseFilter {
// safeguard against mutation
this.matrix = [...matrix];
}
super.setOptions(options);
Object.assign(this, options);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pattern.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class Pattern {
return null;
}

return ctx.createPattern(this.source, this.repeat);
return ctx.createPattern(this.source, this.repeat)!;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/shapes/Object/Object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ export class FabricObject<
this._applyPatternForTransformedGradient(ctx, stroke);
} else {
// is a simple gradient or pattern
ctx.strokeStyle = stroke.toLive(ctx);
ctx.strokeStyle = stroke.toLive(ctx)!;
this._applyPatternGradientTransform(ctx, stroke);
}
} else {
Expand All @@ -1377,7 +1377,7 @@ export class FabricObject<
_setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick<this, 'fill'>) {
if (fill) {
if (isFiller(fill)) {
ctx.fillStyle = fill.toLive(ctx);
ctx.fillStyle = fill.toLive(ctx)!;
this._applyPatternGradientTransform(ctx, fill);
} else {
ctx.fillStyle = fill;
Expand Down Expand Up @@ -1583,7 +1583,7 @@ export class FabricObject<
dims.zoomY / this.scaleY / retinaScaling
);
this._applyPatternGradientTransform(pCtx, filler);
pCtx.fillStyle = filler.toLive(ctx);
pCtx.fillStyle = filler.toLive(ctx)!;
pCtx.fill();
ctx.translate(
-this.width / 2 - this.strokeWidth / 2,
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/line.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class Line extends FabricObject {
// (by copying fillStyle to strokeStyle, since line is stroked, not filled)
const origStrokeStyle = ctx.strokeStyle;
if (isFiller(this.stroke)) {
ctx.strokeStyle = this.stroke.toLive(ctx);
ctx.strokeStyle = this.stroke.toLive(ctx)!;
} else {
ctx.strokeStyle = this.stroke ?? ctx.fillStyle;
}
Expand Down
4 changes: 2 additions & 2 deletions src/shapes/text.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ export class Text<
pCtx.lineTo(0, height);
pCtx.closePath();
pCtx.translate(width / 2, height / 2);
pCtx.fillStyle = filler.toLive(pCtx) || '';
pCtx.fillStyle = filler.toLive(pCtx)!;
this._applyPatternGradientTransform(pCtx, filler);
pCtx.fill();
return pCtx.createPattern(pCanvas, 'no-repeat')!;
Expand Down Expand Up @@ -1243,7 +1243,7 @@ export class Text<
return { offsetX: offsetX, offsetY: offsetY };
} else {
// is a simple gradient or pattern
ctx[property] = filler.toLive(ctx, this) || '';
ctx[property] = filler.toLive(ctx, this)!;
return this._applyPatternGradientTransform(ctx, filler);
}
} else {
Expand Down

0 comments on commit f850db6

Please sign in to comment.