Skip to content

Commit

Permalink
fix(TS): Type fixes and improved JSDOCS. (#9978)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Jul 6, 2024
1 parent 106d508 commit 999f6e1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [next]

## [6.0.2]

- fix(TS): Type fixes and improved JSDOCS. [#9978](https://github.com/fabricjs/fabric.js/pull/9978)

## [6.0.1]

- chore(): export InteractiveFabricObject to tweak default values [#9963](https://github.com/fabricjs/fabric.js/pull/9963)
- chore(): use deconstruction and constants in place of strings to save some bytes of code [#9593](https://github.com/fabricjs/fabric.js/pull/9593)
- tests(): Start moving visual tests to playwrigth [#9481](https://github.com/fabricjs/fabric.js/pull/9481)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"homepage": "http://fabricjs.com/",
"version": "6.0.1",
"version": "6.0.2",
"author": "Juriy Zaytsev <[email protected]>",
"contributors": [
{
Expand Down
8 changes: 8 additions & 0 deletions src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ export class Observable<EventSpec> {
}
}

/**
* Unsubscribe all event listeners for eventname.
* Do not use this pattern. You could kill internal fabricJS events.
* We know we should have protected events for internal flows, but we don't have yet
* @deprecated
* @param {string} eventName event name (eg. 'after:render')
*/
off<K extends keyof EventSpec>(eventName: K): void;
/**
* unsubscribe an event listener
* @param {string} eventName event name (eg. 'after:render')
Expand Down
16 changes: 9 additions & 7 deletions src/shapes/Object/Object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,21 @@ export class FabricObject<
}

/**
* The class type. Used to identify which class this is.
* This is used for serialization purposes and internally it can be used
* to identify classes. As a developer you could use `instance of Class`
* but to avoid importing all the code and blocking tree shaking we try
* to avoid doing that.
* The class type.
* This is used for serialization and deserialization purposes and internally it can be used
* to identify classes.
* When we transform a class in a plain JS object we need a way to recognize which class it was,
* and the type is the way we do that. It has no other purposes and you should not give one.
* Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).
* To idenfity a class use instanceof class ( instanceof Rect ).
* We do not do that in fabricJS code because we want to try to have code splitting possible.
*/
static type = 'FabricObject';

/**
* Legacy identifier of the class. Prefer using utils like isType or instanceOf
* Will be removed in fabric 7 or 8.
* The setter exists because is very hard to catch all the ways in which a type value
* could be set in the instance
* The setter exists to avoid type errors in old code and possibly current deserialization code.
* @TODO add sustainable warning message
* @type string
* @deprecated
Expand Down
4 changes: 2 additions & 2 deletions src/shapes/Text/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ interface UniqueTextProps {
charSpacing: number;
lineHeight: number;
fontSize: number;
fontWeight: string;
fontWeight: string | number;
fontFamily: string;
fontStyle: string;
pathSide: TPathSide;
Expand Down Expand Up @@ -176,7 +176,7 @@ export class FabricText<
* @type {(Number|String)}
* @default
*/
declare fontWeight: string;
declare fontWeight: string | number;

/**
* Font family
Expand Down
1 change: 1 addition & 0 deletions src/util/misc/objectEnlive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export type EnlivenObjectOptions = Abortable & {
};

/**
* @TODO type this correctly.
* Creates corresponding fabric instances from their object representations
* @param {Object[]} objects Objects to enliven
* @param {EnlivenObjectOptions} [options]
Expand Down

0 comments on commit 999f6e1

Please sign in to comment.