observablehq / observablehq/plot
Invalid `floor` invocation from `isTimeInterval`
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 5.4k
- Forks
- 244
- PR merge metrics
- No merged PRs in 30d
Description
Somewhere during binning of temporal data this function is executed:
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:
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the floor call in src/options.js and compare it with the floor signature in src/interval.d.ts. Update the type contract to reflect the no-argument invocation, then verify that the declaration matches the documented binning behavior and type checking succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100