color icon indicating copy to clipboard operation
color copied to clipboard

Typescript conversion?

Open ajmas opened this issue 10 months ago • 6 comments

Given issue #258 would there be any interest in simply converting this to be Typescript based?

ajmas avatar Feb 06 '25 18:02 ajmas

Ehhhhh to be honest I don't know. @LitoMore what do you think?

Qix- avatar Feb 06 '25 21:02 Qix-

BTW I did take an exploratory stab at it (see draft PR), but it will likely introduce some breaking changes and a move a away from the dynamic creation of the conversion methods (this depending on color-convert). I'm going to park the work for now, so I don't spend more energy than necessary.

ajmas avatar Feb 06 '25 21:02 ajmas

Ah, I already have the TypeScript in mind. It is much easier to maintain and update the type definitions with TypeScript. (That's why I sent you @Qix- a friend request on Discord today. I was just about to DM you about rewriting in TypeScript.)

I can rewrite the code of color (after the ESM change), color-convert, and color-string to TypeScript without any API breaking change.

I will draft PRs for them these days.

LitoMore avatar Feb 06 '25 21:02 LitoMore

Yeah really the big thing is color-convert's automatic converter building. As long as that happens then it makes no difference to me if it's typescript or ESM+types.

Qix- avatar Feb 06 '25 21:02 Qix-

Yeah really the big thing is color-convert's automatic converter building. As long as that happens then it makes no difference to me if it's typescript or ESM+types.

Yes. I've read that issue. We could release a patch update to fix the index.d.ts at the moment.

Considering automatic converter building, the TypeScript rewrites might be more appropriate when refactoring for the tree-shaking supports.

LitoMore avatar Feb 06 '25 22:02 LitoMore

I think that's probably ideal given that Typescript can infer return values on the composed types:

Image

Qix- avatar Feb 07 '25 07:02 Qix-