invert-color
invert-color copied to clipboard
TS2345
import invert from 'invert-color';
let _channels = [0, 0, 0];
let _new = invert.asRGB(_channels); //error
expected: This should work, as per:
https://github.com/onury/invert-color/blob/cd183934b67e4536e4e3f8a618067fb861fd63e2/lib/invert.d.ts
/**
* RGB list (array) type with red, green and blue components.
*/
export declare type RgbArray = [number, number, number];
...
export declare type Color = RGB | RgbArray | HexColor;
observed:
TS2345: Argument of type 'number[]' is not assignable to parameter of type 'Color'.
Type 'number[]' is not assignable to type 'RgbArray'.
Target requires 3 element(s) but source may have fewer.
Use as const
assertion:
const _channels = [0, 0, 0] as const;
let _new = invert.asRGB(_channels);