Support string 'rgba' values in signature of scaleLinear().range()
brianrodri opened this issue · comments
Brian Rodriguez commented
The signature of d3.scaleLinear().range
does not accept string arrays as arguments, resulting in compile-time errors.
Observed behavior
The code:
const color = d3.scaleLinear()
.domain([0, d3.max(bins, d => d.length)])
.range(['rgba(255,255,255,0.5)', 'rgba(255,255,255,1.0)']);
...results in the following compile-time TypeScript error:
error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'readonly number[]'.
Type 'string' is not assignable to type 'number'.
Expected behavior
No compile-time error, given that rgba strings are supported by the function.
Mike Bostock commented
It looks like you want to file an issue with D3’s TypeScript bindings, which I don’t maintain. Maybe you meant to file this in the DefinitelyTyped repo? Works for me…