Cannot use with timeFormat when using Typescript
DominicTobias-b1 opened this issue · 1 comments
DominicTobias-b1 commented
Hi, as per this discussion: https://stackoverflow.com/questions/55992937/typescript-error-when-using-d3-timeformat-in-axis-tickformat
We cannot use this with timeFormat e.g.:
axisBottom(x).tickFormat(timeFormat('...'))
Will result in the error:
No overload matches this call.
Overload 1 of 3, '(format: (domainValue: string, index: number) => string): Axis<string>', gave the following error.
Argument of type '(date: Date) => string' is not assignable to parameter of type '(domainValue: string, index: number) => string'.
Types of parameters 'date' and 'domainValue' are incompatible.
Type 'string' is not assignable to type 'Date'.
Overload 2 of 3, '(format: null): Axis<string>', gave the following error.
Argument of type '(date: Date) => string' is not assignable to parameter of type 'null'.ts(2769)
Shouldn't domainValue
be compatible with type date, given this is a very common use case?
The SO solution also does not work at least with TS 3.7.2. Any idea how to fix this? I'm new to the horrors of TS.
mbostock commented
I don’t support any TypeScript bindings, so I’m not sure what the answer is to this question. You’ll probably want to ask the maintainer of the bindings.