uiwjs / react-color

🎨 Is a tiny color picker widget component for React apps.
https://uiwjs.github.io/react-color
MIT License
274 stars 92 forks source link

Add type for Hex color #144

Open ximex opened 5 months ago

ximex commented 5 months ago

add a type for hex-color strings that is a bit stricter than only string. type HexColor = `#${string}`;

jaywcjlove commented 5 months ago

@ximex I can add this type to the package. I tried using the HexColor type, but it may not be easy to use in the code because many places have done error handling, which causes type errors.

https://github.com/uiwjs/react-color/blob/632d4e9201e26b42ee7d5bfeda407144e9a6e2f3/packages/color-convert/src/index.ts#L335-L336

https://github.com/uiwjs/react-color/blob/632d4e9201e26b42ee7d5bfeda407144e9a6e2f3/packages/color-convert/src/index.ts#L339