mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 15:00:26 +00:00
Merge pull request #23997 from NaridaL/chroma-js-fix
[chroma-js] fix bug with Scale.colors.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { Color } from "chroma-js";
|
||||
import chroma = require("chroma-js");
|
||||
|
||||
function test_chroma() {
|
||||
chroma('hotpink');
|
||||
chroma('#ff3399');
|
||||
@@ -187,3 +190,9 @@ function test_types() {
|
||||
const color: chroma.Color = chroma('orange');
|
||||
const scale: chroma.Scale = chroma.scale('RdYlBu');
|
||||
}
|
||||
|
||||
// the following should actually, pass, but TS can't disambiguate between a parameter
|
||||
// which is passed as undefined/null or not passed at all
|
||||
// const scaleColors1: Color[] = chroma.scale(['black', 'white']).colors(12);
|
||||
const scaleColors2: Color[] = chroma.scale(['black', 'white']).colors(12, null);
|
||||
const scaleColors3: Color[] = chroma.scale(['black', 'white']).colors(12, undefined);
|
||||
|
||||
Vendored
+4
-4
@@ -303,10 +303,10 @@ declare namespace chroma {
|
||||
* You can call scale.colors(n) to quickly grab `c` equi-distant colors from a color scale. If called with no
|
||||
* arguments, scale.colors returns the original array of colors used to create the scale.
|
||||
*/
|
||||
colors(c?: number, format?: 'hex' | 'name'): string[];
|
||||
colors(c?: number, format?: null | 'alpha' | 'darken' | 'brighten' | 'saturate' | 'desaturate'): Color[];
|
||||
colors(c?: number, format?: 'luminance' | 'temperature'): number[];
|
||||
colors<K extends keyof ColorSpaces>(c?: number, format?: K): Array<ColorSpaces[K]>;
|
||||
colors(c: number | undefined, format: undefined | null | 'alpha' | 'darken' | 'brighten' | 'saturate' | 'desaturate'): Color[];
|
||||
colors(c: number | undefined, format: 'luminance' | 'temperature'): number[];
|
||||
colors<K extends keyof ColorSpaces>(c: number | undefined, format: K): Array<ColorSpaces[K]>;
|
||||
colors(c: number | undefined, format?: 'hex' | 'name'): string[];
|
||||
|
||||
/**
|
||||
* If you want the scale function to return a distinct set of colors instead of a continuous gradient, you can
|
||||
|
||||
Reference in New Issue
Block a user