Closed Ciwan1859 closed 8 years ago
The angle-brackets signify that Range
and Output
are generic types, which need to be specified by you, when using the interface ScaleLinear
, or the corresponding scale generator scaleLinear
.
If you look at the shape tests in the definitions test file, you will see some examples of how they can be utilized, see here
Essentially, Range
corresponds to the 'raw' type of elements you specify for the linear scale range(...)
. Output
corresponds to the type of elements actually output by your linear scale after an interpolator
has been applied to calculate a range value. I.e. an interpolator configured for the scale using its interpolate(...)
method, can change the type from Range
to Output
in the process of mapping. See here in the API documents. E.g. a numeric range value of 100
could be mapped to an output value of 100px
.
If you have further questions, feel free to use StackOverflow.
P.S. When I find some time, d3-shape is one of the definition files on my radar to include more comprehensive JSDoc comments. All definitions developed in this repo are now maintained on DefinititelyTypes (feeding npm @types). I am already tracking an issue for enhanced comments there.
For those, I have gotten around to, the JSDoc comments are an adaptation of the actual D3 API comments with added information, like the meaning of the generics for a given interface or method.
Any genuine issues with the definitions (bugs, omissions, enhancements and the like) should be opened on DT. Questions on how to use them should be directed to stackOverflow or similar forums. Not the least, because that is probably where others will look first as well. Cheers.
Hello
I have an interface that has the following property in the TypeScript class:
import * as d3Scale from 'd3-scale';
yRange: d3Scale.ScaleLinear<Range, Output>;
I have all my imports correct, but VS Code is complaining that it can't find
Output
. It says:What am I doing wrong? I should be able to use that in my interface no?
Any help would be greatly appreciated.