color-js / color.js

Color conversion & manipulation library by the editors of the CSS Color specifications
https://colorjs.io
MIT License
1.81k stars 80 forks source link

Incompatible with `typescript@5.5.2` #560

Closed jlarmstrongiv closed 1 week ago

jlarmstrongiv commented 2 weeks ago

Reproduction https://github.com/jlarmstrongiv/colorjsio-ts

image
LeaVerou commented 2 weeks ago

Hi @jlarmstrongiv, is this about the dev branch or the currently released v0.5.0?

jlarmstrongiv commented 2 weeks ago

Hi @LeaVerou this issue is about colorjs.io@0.5.0 with typescript@5.5.2

LeaVerou commented 2 weeks ago

Ah okay. We've made some major changes wrt typing in v0.6.0 and we’re still not done. We’ll do an alpha soon, please check it out to see if you still have this issue?

kachkaev commented 2 weeks ago

I was able to patch colorjs.io@0.5.0 like this:

patches/colorjs.io@0.5.0.patch

diff --git a/types/src/index.d.ts b/types/src/index.d.ts
index 73bc03a39431333a8c9a4a2e9c24b4bb0d8e693a..63382d9984fa81cf9919423750384c5e4d10361a 100644
--- a/types/src/index.d.ts
+++ b/types/src/index.d.ts
@@ -1,5 +1,5 @@
 import { uv, xy } from "./chromaticity.js";
-import Color, { ColorTypes, ToColorPrototype } from "./color.js";
+import BaseColor, { ColorTypes, ToColorPrototype } from "./color.js";
 import contrast from "./contrast.js";
 import {
    contrastWCAG21,
@@ -24,7 +24,8 @@ import { lighten, darken } from "./variations.js";

 // Augment existing Color object
 declare module "./color" {
-   export default class Color {
+   // https://github.com/color-js/color.js/issues/560
+   export default class Color extends BaseColor {
        // chromaticity
        uv: ToColorPrototype<typeof uv>;
        xy: ToColorPrototype<typeof xy>;

This seems to unblock typescript 5.45.5 migration. @LeaVerou WDYT of releasing 0.5.1 with this patch?

jlarmstrongiv commented 2 weeks ago

Sure 👍 Let me know when you make an alpha release of v0.6.0 or a patch release of 0.5.1 and I’ll give it a go

MysteryBlokHed commented 1 week ago

@jlarmstrongiv Could you check whether this error still happens on v0.5.2?

jlarmstrongiv commented 1 week ago

@MysteryBlokHed thank you! I can confirm the error is resolved on v0.5.2 👍