Skip to content

fix(types): make time scale parser and tooltipFormat optional - #12311

Open
galshir wants to merge 2 commits into
chartjs:masterfrom
galshir:fix/time-scale-optional-parser
Open

galshir wants to merge 2 commits into
chartjs:masterfrom
galshir:fix/time-scale-optional-parser

Conversation

@galshir

@galshir galshir commented Sep 14, 2026

Copy link
Copy Markdown

Fixes #12003

Problem

TimeScaleTimeOptions declares every member as required, including time.parser and time.tooltipFormat. Neither option has a default value (see the options table in docs/axes/cartesian/time.md, where both rows have an empty Default column) and both are guarded at runtime:

  • TimeScale#parse() only uses the parser when it is a function or a string
  • TimeScale#getLabelForValue() falls back to displayFormats.datetime when tooltipFormat is not set

As a result, anyone who annotates a value with the exported TimeScaleTimeOptions type is forced to supply a parser, and there is no sensible value to supply when a date adapter is already configured.

Change

Mark parser and tooltipFormat as optional. All other members do have defaults in TimeScale.defaults, so they stay required.

This is a type-only change and non-breaking: user facing config already goes through DeepPartial, so no existing configuration changes meaning, and widening a required property to an optional one cannot break existing object literals.

Tests

Added test/types/scales/time_options.ts, covering a minimal object without parser/tooltipFormat, plus the string parser and function parser forms.

Neither option has a default in the time scale and both are guarded at runtime, so they should not be required members of TimeScaleTimeOptions.

Fixes chartjs#12003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TimeScaleTimeOptions requires parser

1 participant