-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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): WIP - Convert utils #8123
Conversation
* @param {TRadian} radians value in radians | ||
* @return {TDegree} value in degrees | ||
*/ | ||
export const radiansToDegrees = (radians: TRadian): TDegree => (radians / PiBy180) as TDegree; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beautiful
src/util/misc/sin.ts
Outdated
let value = 1; | ||
if (angle < 0) { | ||
// sin(-a) = -sin(a) | ||
value = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a const?
value = -1; | |
value = Math.sign(angle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i always forget about Math.sign
i know what i broke, i ll try to fix it today. |
@ShaMan123 i had to revert a couple of imports. |
* @param {*} value | ||
* @return {Array} original array | ||
*/ | ||
export const removeFromArray = (array: any[], value: any): any[] => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i m sure there is a way to tell Typescript that the returned array is the same type of the input array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generic types
export const removeFromArray = (array: any[], value: any): any[] => { | |
export function removeFromArray<T>(array: T[], value: T): T[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and of course T can be a mix of types. ( even if in our case often isn't )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fat arrows aren't good for TS as functions?
Ok something broke with the import system and i had to patch it. I have no idea why. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the circular import
I have seen it as well and managed to fix it in a different way without reverting
Try importing utils directly and not from the util
index OR make animate_color
or whatever a module (even as a hack).
That should fix it.
rollup seems to be a decent tool
src/mixins/observable.mixin.ts
Outdated
@@ -1,6 +1,7 @@ | |||
//@ts-nocheck | |||
(function(global) { | |||
var fabric = global.fabric; | |||
console.log(fabric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i was investigating why fabric was undefined
This reverts commit 9a79f9c.
prevent import cycle
Code Coverage Summary
|
Can't be generic i thinl
בתאריך יום ד׳, 10 באוג׳ 2022, 19:28, מאת Andrea Bogazzi <
***@***.***>:
… ***@***.**** commented on this pull request.
------------------------------
In src/util/internals/removeFromArray.ts
<#8123 (comment)>:
> @@ -0,0 +1,16 @@
+/**
+ * Removes value from an array.
+ * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`
+ * @static
+ * @memberof fabric.util
+ * @param {Array} array
+ * @param {*} value
+ * @return {Array} original array
+ */
+export const removeFromArray = (array: any[], value: any): any[] => {
fat arrows aren't good for TS as functions?
—
Reply to this email directly, view it on GitHub
<#8123 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIGAW4PO32BB4AWGBPQ74HDVYPKC7ANCNFSM55UAKANQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
src/util/misc/vectors.ts
Outdated
* @param {Point} to | ||
* @returns {Point} vector | ||
*/ | ||
export const createVector = (from: IPoint, to: IPoint): Point => new Point(to).subtract(from); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't get this. if the type was Point , way we changed it to interface? we expect devs to use points or objects with x/y?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right
I committed it and felt the same
Reverr this
And safeguard createVector instead
note for later self: |
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Co-authored-by: ShaMan123 <shacharnen@gmail.com>
This will be a partial conversion of utils, i will stop at the misc file and review/merge.
All together is a mess, but luckily we can also swap the imports at that point.