color-js/color.js

Incompatible with `typescript@5.5.2`

Closed this issue · 7 comments

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

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

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?

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?

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

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

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