Merge pull request #23997 from NaridaL/chroma-js-fix

[chroma-js] fix bug with Scale.colors.
This commit is contained in:
Armando Aguirre
2018-03-08 16:34:30 -08:00
committed by GitHub
2 changed files with 13 additions and 4 deletions
+9
View File
@@ -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);
+4 -4
View File
@@ -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