Refactor Color types for BC with @types/color#278
Refactor Color types for BC with @types/color#278mindplay-dk wants to merge 1 commit intoQix-:masterfrom
Conversation
|
That's different. Our exported |
|
Your exported As explained, it is conventional in TS for constructors and types to use the same name - for class Color {
constructor(private value: string) {}
}
function setColor(color: Color) {
// ...
}
setColor(new Color("#fff"))The Having The community-provided third-party types followed this TS convention. I realize it is just a function in normal use, but you named it Lines 23 to 25 in 4fda9a3 Type names and variable names do not occupy the same namespace in TS - the Importing Please reconsider. 🙂🙏 |
The built-in types that came with v5 contained an annoying breaking change vs `@types/color`, in which a new, separate type `ColorInstance` needs to be imported separately, and `Color` itself is not a type and can't be use in type-hints anymore. It is conventional for constructors and instance types to be self-contained, as they are with native `class` declarations.
|
I've amended my PR to better comply with the linter rules, updated the tests for the types and added a test to demonstrate backwards compatibility with @Qix- can you approve this PR to run please? |
|
@Qix- hello? :-) |
|
To others looking for a workaround until this gets fixed:
This will override the built-in types. You can add the missing oklch methods as well, if needed - just copy and rename the |
The built-in types that came with v5 contained an annoying breaking change vs
@types/color, in which a new, separate typeColorInstanceneeds to be imported separately, andColoritself is not a type and can't be use in type-hints anymore.To illustrate the problem that was introduced:
It is conventional for constructors and instance types to be self-contained, as they are with native
classdeclarations.With this change in place:
To avoid a breaking change vs v5 types, this PR retains the newly introduced
ColorInstanceas an alias forColor.