Somewhere during binning of temporal data this function is executed:
|
export function isTimeInterval(t) { |
|
return isInterval(t) && typeof t?.floor === "function" && t.floor() instanceof Date; |
|
} |
Notice that no argument is passed to floor when the function tries to figure out if the result type is a Date.
This is in conflict with the type definitions, which indicate that a parameter to floor is guaranteed:
|
/** A custom interval implementation. */ |
|
export interface IntervalImplementation<T> { |
|
/** |
|
* Returns the value representing the greatest interval boundary less than or |
|
* equal to the specified *value*. For example, day.floor(*date*) typically |
|
* returns 12:00 AM on the given date. |
|
* |
|
* This method is idempotent: if the specified value is already floored to the |
|
* current interval, the same value is returned. Furthermore, the returned |
|
* value is the minimum expressible value of the associated interval, such |
|
* that floor(floor(*value*) - *epsilon*) returns the preceding interval |
|
* boundary value. |
|
*/ |
|
floor(value: T): T; |
I believe the simplest fix would be
- */
- floor(value: T): T
+ *
+ * If no value is passed, the function is expected to return *any* result
+ * matching its return type.
+ */
+ floor(value?: T): T
Related: #2423
Edit: I just noted that this behaviour is documented on the Bin transform page (but not the Interval transform), which increases my confidence that it’s really just the type that’s off.
Time intervals are intervals that are also functions that return a Date instance when called with no arguments.
Somewhere during binning of temporal data this function is executed:
plot/src/options.js
Lines 428 to 430 in 356f579
Notice that no argument is passed to
floorwhen the function tries to figure out if the result type is a Date.This is in conflict with the type definitions, which indicate that a parameter to
flooris guaranteed:plot/src/interval.d.ts
Lines 34 to 47 in 356f579
I believe the simplest fix would be
Related: #2423
Edit: I just noted that this behaviour is documented on the Bin transform page (but not the Interval transform), which increases my confidence that it’s really just the type that’s off.