Skip to content

Commit

Permalink
[types] Add missing types for features in v0.4.1
Browse files Browse the repository at this point in the history
Updates the types to include changes that were missed in v0.4.1,
specifically from PR's color-js#209 and color-js#219.
  • Loading branch information
MysteryBlokHed committed Nov 16, 2022
1 parent b4cadc2 commit 5f5c169
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions types/src/color.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ declare class Color {
jzazbz: SpaceAccessor;
jzczhz: SpaceAccessor;
lab: SpaceAccessor;
lab_d65: SpaceAccessor;
lch: SpaceAccessor;
oklab: SpaceAccessor;
oklch: SpaceAccessor;
Expand Down
5 changes: 5 additions & 0 deletions types/src/contrast/deltaPhi.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ColorTypes } from "../color";
export default function (
background: ColorTypes,
forgeround: ColorTypes
): number;
1 change: 1 addition & 0 deletions types/src/contrast/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export { default as contrastAPCA } from "./APCA";
export { default as contrastMichelson } from "./Michelson";
export { default as contrastWeber } from "./Weber";
export { default as contrastLstar } from "./Lstar";
export { default as contrastDeltaPhi } from "./deltaPhi";
3 changes: 3 additions & 0 deletions types/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
contrastMichelson,
contrastWeber,
contrastLstar,
contrastDeltaPhi,
} from "../src/contrast/index";
import deltaE from "../src/deltaE";
import {
Expand All @@ -31,6 +32,7 @@ declare namespace Color {
contrastMichelson,
contrastWeber,
contrastLstar,
contrastDeltaPhi,
};
// deltaE
export {
Expand Down Expand Up @@ -62,6 +64,7 @@ declare class Color extends ColorImport {
contrastMichelson: ToColorPrototype<typeof contrastMichelson>;
contrastWeber: ToColorPrototype<typeof contrastWeber>;
contrastLstar: ToColorPrototype<typeof contrastLstar>;
contrastDeltaPhi: ToColorPrototype<typeof contrastDeltaPhi>;

// deltaE
deltaE: ToColorPrototype<typeof deltaE>;
Expand Down
1 change: 1 addition & 0 deletions types/src/interpolation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function range(
export interface MixOptions {
space?: string | ColorSpace | undefined;
outputSpace?: string | ColorSpace | undefined;
premultiplied?: boolean | undefined;
}

export function mix(
Expand Down
1 change: 1 addition & 0 deletions types/src/spaces/index-fn.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { default as XYZ_D65 } from "./xyz-d65";
export { default as XYZ_D50 } from "./xyz-d50";
export { default as XYZ_ABS_D65 } from "./xyz-abs-d65";
export { default as Lab } from "./lab";
export { default as Lab_D65 } from "./lab-d65";
export { default as LCH } from "./lch";
export { default as sRGB_Linear } from "./srgb-linear";
export { default as sRGB } from "./srgb";
Expand Down
3 changes: 3 additions & 0 deletions types/src/spaces/lab-d65.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ColorSpace from "../space";
declare const _default: ColorSpace;
export default _default;
7 changes: 6 additions & 1 deletion types/test/interpolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ mix("red", "blue"); // $ExpectType number
mix("red", "blue", 0.5); // $ExpectType number
mix("red", "blue", {}); // $ExpectType number
mix("red", "blue", 0.5, {}); // $ExpectType number
mix("red", "blue", { space: "srgb", outputSpace: "srgb_linear" }); // $ExpectType number
// $ExpectType number
mix("red", "blue", {
space: "srgb",
outputSpace: "srgb_linear",
premultiplied: true,
});

steps("red", "blue"); // $ExpectType Color[]
steps(r, " blue"); // $ExpectType Color[]
Expand Down

0 comments on commit 5f5c169

Please sign in to comment.