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

Adding TS to rollup #8019

Merged
merged 6 commits into from
Jun 25, 2022
Merged

Adding TS to rollup #8019

merged 6 commits into from
Jun 25, 2022

Conversation

asturur
Copy link
Member

@asturur asturur commented Jun 22, 2022

Didn't test yet, just push up for visibility

Copy link
Contributor

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

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

WOW!

rollup.config.js Show resolved Hide resolved
@ShaMan123
Copy link
Contributor

@asturur you should write about this in the tracker issue

Comment on lines +10 to +11
export type TDegree = Nominal<number, Degree>;
export type TRadian = Nominal<number, Radian>;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is soething i have seen doing to other devs, is like a away to have 2 numbers that do not mix together.
This is good for radians vs degree and little else probably in our case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked at the angle=-angle thing
As you can see if I call cos(number) typescript will mark it as well unless I typecast it
The Nominal type needs more work.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

If I add an optional mark to the nominalTag 304767d it accepts number or TRadian but not TDegree:
image

image

Copy link
Member Author

Choose a reason for hiding this comment

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

oh that would be fine, important is that they don't mix when they come out of a function that specifically outputs either radians or degree, i'll make that change.

Typescript should have this partitioned number somehow, even if is not a specific TS use case, but is a nice to have functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

very nice to have

Comment on lines +13 to +21
export const cos = (angle: TRadian): number => {
if (angle === 0) { return 1; }
var angleSlice = Math.abs(angle) / halfPI;
switch (angleSlice) {
case 1: case 3: return 0;
case 2: return -1;
}
return Math.cos(angle);
};
Copy link
Member Author

Choose a reason for hiding this comment

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

i like the idea of one function per file and a file of constants.
I m also fine with a file grouping for example cos, sin, degreeToRadians and radiansToDegree, but not much else.

But since rollup has zero footprint on file numbers for me a function per file gives me easy accessibility to code, i can find the function both in the search and in the file search and i don't have to scroll files of thousands of lines searching the utils.

Copy link
Contributor

@ShaMan123 ShaMan123 Jun 22, 2022

Choose a reason for hiding this comment

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

I don't mind if a file for each or grouping.
We should then put cos, sin ,rad/deg utils into a seprate folder IMO called trig or something

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, a code styling question, I don't have an opinion.
export const cos vs export function cos, why do you prefer the first?

This will make fabric so clean. I am very excited

Copy link
Member Author

Choose a reason for hiding this comment

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

For top leveI functions is just an aestetic preference, i m not sure if there is a meaningful difference in functionality or speed. If there was i think it would be well chatted on the internet.

@asturur
Copy link
Member Author

asturur commented Jun 25, 2022

ok this works, tests pass, i add it to the general build process pr.
Next is eslint update

@asturur asturur merged commit ea324d6 into rollup-no-ws Jun 25, 2022
@asturur asturur deleted the rollup-and-ts branch September 11, 2022 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants