Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12003
Problem
TimeScaleTimeOptionsdeclares every member as required, includingtime.parserandtime.tooltipFormat. Neither option has a default value (see the options table indocs/axes/cartesian/time.md, where both rows have an emptyDefaultcolumn) and both are guarded at runtime:TimeScale#parse()only uses the parser when it is a function or a stringTimeScale#getLabelForValue()falls back todisplayFormats.datetimewhentooltipFormatis not setAs a result, anyone who annotates a value with the exported
TimeScaleTimeOptionstype is forced to supply aparser, and there is no sensible value to supply when a date adapter is already configured.Change
Mark
parserandtooltipFormatas optional. All other members do have defaults inTimeScale.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 withoutparser/tooltipFormat, plus the string parser and function parser forms.