chroma.js icon indicating copy to clipboard operation
chroma.js copied to clipboard

Property 'hue' does not exist on type 'Cubehelix'.

Open w-p opened this issue 5 years ago • 1 comments

In a Vue / Typescript project, hue() is not found on Cubehelix:

59:8 Property 'hue' does not exist on type 'Cubehelix'.
    57 |       .start(0)
    58 |       .rotations(1)
  > 59 |       .hue(3)
       |        ^
    60 |       .gamma(0.4)
    61 |       .lightness([0.6, 0.6])
    62 |       .scale()
Version: typescript 3.3.1, tslint 5.12.1

In node, no problem:

> chroma.cubehelix().start(0).rotations(1).hue(3).gamma(0.4).lightness([0.6, 0.6]).scale().colors(5)
[ '#ffab97', '#a4f96d', '#73f5ff', '#fca7ff', '#ffab97' ]

package.json:

"chroma-js": "^2.0.3",
"@types/chroma-js": "^1.4.1",

I think the hue() function signature is just missing from @types/chroma-js here though I didn't dig far.

After modifying @types/chroma-js/index.d.ts, things appears to be compiling OK:

interface Cubehelix {
  ...
  hue(h: number): Cubehelix;
  ...
}

w-p avatar Apr 05 '19 13:04 w-p

I am pretty sure the issue should go to the people at DefinitelyTyped.

Artoria2e5 avatar Apr 09 '21 15:04 Artoria2e5