Skip to content

Commit

Permalink
chore(TS): migrate Group and ActiveSelectin (#8455)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 authored Nov 26, 2022
1 parent e8f623b commit 59e6a22
Show file tree
Hide file tree
Showing 15 changed files with 1,176 additions and 1,185 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): migrate Group/ActiveSelection [#8455](https://github.com/fabricjs/fabric.js/pull/8455)
- fix(TS): migration error of itext key mixin (#8421) [#8457](https://github.com/fabricjs/fabric.js/pull/8457)
- chore(TS): migrate text classes/mixins [#8421](https://github.com/fabricjs/fabric.js/pull/8421)
- chore(TS): migrate Image [#8443](https://github.com/fabricjs/fabric.js/pull/8443)
Expand Down
1 change: 0 additions & 1 deletion src/__types__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ export type StaticCanvas = Record<string, any> & {
};
getRetinaScaling(): number;
} & Observable;
export type TObject = any;
6 changes: 1 addition & 5 deletions src/brushes/circle_brush.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import { Color } from '../color';
import { Point } from '../point.class';
import { Shadow } from '../shadow.class';
import { Circle } from '../shapes/circle.class';
import { Group } from '../shapes/group.class';
import { getRandomInt } from '../util/internals';
import { Canvas } from '../__types__';
import { BaseBrush } from './base_brush.class';

/**
* @todo remove transient
*/
const { Group } = fabric;

export type CircleBrushPoint = {
x: number;
y: number;
Expand Down
6 changes: 1 addition & 5 deletions src/brushes/spray_brush.class.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { fabric } from '../../HEADER';
import { Point } from '../point.class';
import { Group } from '../shapes/group.class';
import { Shadow } from '../shadow.class';
import { Rect } from '../shapes/rect.class';
import { getRandomInt } from '../util/internals';
import { Canvas } from '../__types__';
import { BaseBrush } from './base_brush.class';

/**
* @todo remove transient
*/
const { Group } = fabric;

export type SprayBrushPoint = {
x: number;
y: number;
Expand Down
2 changes: 0 additions & 2 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class Cache {
* measurement and so wrong bounding boxes.
* After the font cache is cleared, either change the textObject text content or call
* initDimensions() to trigger a recalculation
* @memberOf fabric.util
* @param {String} [fontFamily] font family to clear
*/
clearFontCache(fontFamily?: string) {
Expand All @@ -62,7 +61,6 @@ export class Cache {
/**
* Given current aspect ratio, determines the max width and height that can
* respect the total allowed area for the cache.
* @memberOf fabric.util
* @param {number} ar aspect ratio
* @return {number[]} Limited dimensions X and Y
*/
Expand Down
10 changes: 7 additions & 3 deletions src/mixins/collection.mixin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { fabric } from '../../HEADER';
import type { FabricObject } from '../shapes/fabricObject.class';

export function createCollectionMixin(Klass: { new (...args: any[]): any }) {
export function createCollectionMixin<T extends { new (...args: any[]): any }>(
Klass: T
) {
return class Collection extends Klass {
/**
* @type {FabricObject[]}
Expand Down Expand Up @@ -123,7 +125,7 @@ export function createCollectionMixin(Klass: { new (...args: any[]): any }) {
/**
* Returns true if collection contains an object.\
* **Prefer using {@link `FabricObject#isDescendantOf`} for performance reasons**
* instead of a.contains(b) use b.isDescendantOf(a)
* instead of `a.contains(b)` use `b.isDescendantOf(a)`
* @param {Object} object Object to check against
* @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`
* @return {Boolean} `true` if collection contains an object
Expand All @@ -133,7 +135,9 @@ export function createCollectionMixin(Klass: { new (...args: any[]): any }) {
return true;
} else if (deep) {
return this._objects.some(
(obj) => obj instanceof Collection && obj.contains(object, true)
(obj) =>
obj instanceof Collection &&
(obj as unknown as Collection).contains(object, true)
);
}
return false;
Expand Down
1 change: 0 additions & 1 deletion src/pattern.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export class Pattern {
* Constructor
* @param {Object} [options] Options object
* @param {option.source} [source] the pattern source, eventually empty or a drawable
* @return {fabric.Pattern} thisArg
*/
constructor(options: TPatternOptions = {}) {
this.id = FabricObject.__uid++;
Expand Down
Loading

0 comments on commit 59e6a22

Please sign in to comment.