Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(TS): Group #8455

Merged
merged 31 commits into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4b46dd6
init
ShaMan123 Nov 21, 2022
4fc4319
Update collection.mixin.ts
ShaMan123 Nov 21, 2022
84a75de
types
ShaMan123 Nov 21, 2022
339e8c1
Update object_interactivity.mixin.ts
ShaMan123 Nov 21, 2022
76f26d6
Update object.class.ts
ShaMan123 Nov 21, 2022
82ded9b
Update collection.mixin.ts
ShaMan123 Nov 21, 2022
a97d170
Update group.class.ts
ShaMan123 Nov 21, 2022
b4e85c2
Update group.js
ShaMan123 Nov 21, 2022
305e9bd
Update CHANGELOG.md
ShaMan123 Nov 21, 2022
07fbc40
Update group.class.ts
ShaMan123 Nov 21, 2022
9f187cb
Squashed commit of the following:
ShaMan123 Nov 21, 2022
4fe445f
Update group.class.ts
ShaMan123 Nov 21, 2022
c36121d
migrate AS
ShaMan123 Nov 21, 2022
9ac6ec3
Update active_selection.class.ts
ShaMan123 Nov 21, 2022
a77f803
Update activeselection.js
ShaMan123 Nov 21, 2022
69f5c38
Update active_selection.class.ts
ShaMan123 Nov 21, 2022
4e8db1a
remove redundant deep clone
ShaMan123 Nov 21, 2022
2061e5b
Revert "Squashed commit of the following:"
ShaMan123 Nov 21, 2022
3523a0b
rename
ShaMan123 Nov 21, 2022
7510e6c
Update active_selection.class.ts
ShaMan123 Nov 21, 2022
45abc34
TS complaining
ShaMan123 Nov 23, 2022
806b6e7
fix(): `_onAfterObjectsChange`
ShaMan123 Nov 23, 2022
13f6613
port group changes from #7878
ShaMan123 Nov 23, 2022
b3fb13e
Merge branch 'master' into ts-group
ShaMan123 Nov 25, 2022
68d2280
fix merge conflict
ShaMan123 Nov 25, 2022
7b33323
more cleanup
ShaMan123 Nov 25, 2022
971c4d3
cleanup
ShaMan123 Nov 25, 2022
cf82a83
temporary fix
ShaMan123 Nov 25, 2022
e1cb367
checkout patternBrush
ShaMan123 Nov 25, 2022
98c0ae4
Merge branch 'master' into ts-group
asturur Nov 26, 2022
7149280
added comment
asturur Nov 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
- chore(TS): migrate text classes/mixins [#8408](https://github.com/fabricjs/fabric.js/pull/8408)
- chore(TS): migrate Collection [#8433](https://github.com/fabricjs/fabric.js/pull/8433)
- ci(): Simplify filestats even more [#8449](https://github.com/fabricjs/fabric.js/pull/8449)
Expand Down
2 changes: 0 additions & 2 deletions src/__types__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ export type StaticCanvas = Record<string, any> & {
};
getRetinaScaling(): number;
} & Observable;
export type Rect = any;
export type TObject = any;
6 changes: 4 additions & 2 deletions src/brushes/spray_brush.class.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { fabric } from '../../HEADER';
import { Point } from '../point.class';
import { Group } from '../shapes/group.class';
import { Rect } from '../shapes/rect.class';
import { getRandomInt } from '../util/internals';
import { Canvas, Rect } from '../__types__';
import { Canvas } from '../__types__';
import { BaseBrush } from './base_brush.class';

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

export type SprayBrushPoint = {
x: number;
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS doesn't manage to cope with this line

);
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/mixins/object_interactivity.mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class InteractiveFabricObject extends FabricObject {
* Constructor
* @param {Object} [options] Options object
*/
constructor(options: Record<string, unknown>) {
constructor(options?: Record<string, unknown>) {
super(options);
}

Expand Down
Loading