Repository navigation
[d3] Correct interpolate() signature - #5095
Conversation
|
d3/d3.d.ts to authors(@gustavderdrache @borisyankov). could you review this PR? check list
|
|
Boy, this really is obnoxious. I feel pretty strongly that this is at least partly related to d3 not actually upcasting values when it arguably should be. The compiler bug also affects typeof d3.svg.line().x(5).x() === 'number'
typeof d3.svg.line().x(d3.functor(5)).x() === 'function'when really both should be upcast by As far as fixing this goes, it's worth taking a look at other setter/getter patterns that are affected by this bug (at least other SVG generators like |
|
@gustavderdrache @borisyankov What is the status of this? I would like if we could merge this in, then go for a more general fix (i.e. fix it everywhere else this happens) |
|
👍 I'd rather have the full fix (along with unit tests), but this is a step in the right direction. |
[d3] Correct interpolate() signature
This code would not have compiled before
It compiles now.
The reason for that is described here
microsoft/TypeScript#1805
In short, since the return type of interpolate is the union
string | ((points: Array<[number, number]>) => string), that is what the argument should look like as well. Splitting it into overloaded methods does not work until TS#1805 is closed