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): Update Typescript to 5.5.4 #10044

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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): Update TS to latest [#10044](https://github.com/fabricjs/fabric.js/pull/10044)
- feat(): Add has method to classRegistry to allow to check if a class exists. (fixes #10001)

## [6.1.0]
Expand Down
146 changes: 73 additions & 73 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@
"prettier": "2.7.1",
"ps-list": "^8.1.0",
"qunit": "^2.17.2",
"rollup": "^4.9.5",
"rollup": "^4.20.0",
"semver": "^7.3.8",
"source-map-support": "^0.5.21",
"testem": "^3.8.0",
"tslib": "^2.4.1",
"typescript": "^4.9.4",
"typescript": "^5.5.4",
"v8-to-istanbul": "^9.1.0"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/EventTypeDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,6 @@ export interface CanvasEvents
// IText
'text:selection:changed': { target: IText };
'text:changed': { target: IText };
'text:editing:entered': { target: IText };
'text:editing:entered': { target: IText } & Partial<TEvent>;
'text:editing:exited': { target: IText };
}
7 changes: 1 addition & 6 deletions src/Shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,7 @@ export class Shadow {
constructor(arg0: string | Partial<TClassProperties<Shadow>>) {
const options: Partial<TClassProperties<Shadow>> =
typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;
Object.assign(this, Shadow.ownDefaults);
for (const prop in options) {
// @ts-expect-error for loops are so messy in TS
this[prop] = options[prop];
}

Object.assign(this, Shadow.ownDefaults, options);
this.id = uid();
}

Expand Down
26 changes: 11 additions & 15 deletions src/canvas/DOMManagers/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LEFT, NONE, TOP } from '../../constants';
import { NONE } from '../../constants';
import type { TSize } from '../../typedefs';
import {
getDocumentFromElement,
Expand Down Expand Up @@ -50,25 +50,21 @@ export const setCSSDimensions = (
* @return {Object} Object with "left" and "top" properties
*/
export function getElementOffset(element: HTMLElement) {
let box = { left: 0, top: 0 };
const doc = element && getDocumentFromElement(element),
offset = { left: 0, top: 0 },
offsetAttributes = {
borderLeftWidth: LEFT,
borderTopWidth: TOP,
paddingLeft: LEFT,
paddingTop: TOP,
} as const;
offset = { left: 0, top: 0 };

if (!doc) {
return offset;
}
const elemStyle =
getWindowFromElement(element)?.getComputedStyle(element, null) || {};
for (const attr in offsetAttributes) {
// @ts-expect-error TS learn to iterate!
offset[offsetAttributes[attr]] += parseInt(elemStyle[attr], 10) || 0;
}
const elemStyle: CSSStyleDeclaration =
getWindowFromElement(element)?.getComputedStyle(element, null) ||
({} as CSSStyleDeclaration);
offset.left += parseInt(elemStyle.borderLeftWidth, 10) || 0;
offset.top += parseInt(elemStyle.borderTopWidth, 10) || 0;
offset.left += parseInt(elemStyle.paddingLeft, 10) || 0;
offset.top += parseInt(elemStyle.paddingTop, 10) || 0;

let box = { left: 0, top: 0 };

const docElem = doc.documentElement;
if (typeof element.getBoundingClientRect !== 'undefined') {
Expand Down
3 changes: 1 addition & 2 deletions src/filters/BaseFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ export class BaseFilter<
return {
type: this.type,
...defaultKeys.reduce<OwnProps>((acc, key) => {
//@ts-expect-error TS doesn't get i want an object that looks like this
acc[key] = this[key as keyof this];
acc[key] = this[key as keyof this] as unknown as typeof acc[typeof key];
return acc;
}, {} as OwnProps),
};
Expand Down
Loading
Loading