From 8eeae7213d122af3c16e87660dc0782ae4b1db69 Mon Sep 17 00:00:00 2001 From: Manuel Meister Date: Sun, 18 Jun 2023 10:50:14 +0200 Subject: [PATCH] [types] Add missing string option type in toGamut --- src/toGamut.js | 2 +- types/src/toGamut.d.ts | 2 +- types/test/toGamut.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/toGamut.js b/src/toGamut.js index d68ee3549..a2e62a480 100644 --- a/src/toGamut.js +++ b/src/toGamut.js @@ -12,7 +12,7 @@ import getColor from "./getColor.js"; /** * Force coordinates to be in gamut of a certain color space. * Mutates the color it is passed. - * @param {Object} options + * @param {Object|string} options object or spaceId string * @param {string} options.method - How to force into gamut. * If "clip", coordinates are just clipped to their reference range. * If in the form [colorSpaceId].[coordName], that coordinate is reduced diff --git a/types/src/toGamut.d.ts b/types/src/toGamut.d.ts index fc6f94dfe..842a4a66c 100644 --- a/types/src/toGamut.d.ts +++ b/types/src/toGamut.d.ts @@ -10,7 +10,7 @@ declare function toGamut( options?: { method?: string | undefined; space?: string | ColorSpace | undefined; - } + } | string ): PlainColorObject; export default toGamut; diff --git a/types/test/toGamut.ts b/types/test/toGamut.ts index 4a77921e7..d9f97fb92 100644 --- a/types/test/toGamut.ts +++ b/types/test/toGamut.ts @@ -10,3 +10,4 @@ toGamut("red"); // $ExpectType PlainColorObject toGamut(new Color("red")); // $ExpectType PlainColorObject toGamut(new Color("red"), { method: "clip", space: "srgb" }); // $ExpectType PlainColorObject toGamut(new Color("red"), { method: "clip", space: sRGB }); // $ExpectType PlainColorObject +toGamut(new Color("red"), "srgb"); // $ExpectType PlainColorObject