Export CallbackDataParams and TopLevelFormatterParams for formatter callbacks#21690
Open
kirthi-b wants to merge 1 commit into
Open
Export CallbackDataParams and TopLevelFormatterParams for formatter callbacks#21690kirthi-b wants to merge 1 commit into
kirthi-b wants to merge 1 commit into
Conversation
Re-export CallbackDataParams and TopLevelFormatterParams from the core
export so tooltip.formatter and label.formatter callbacks can be typed
with `import type { ... } from 'echarts'` instead of reaching into
internal paths like 'echarts/types/dist/shared'.
Closes apache#14277
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.
What does this PR do?
This exports the types of the
paramsargument that ECharts passes to formatter callbacks, so TypeScript users can type those callbacks without reaching into internal paths.Two types are now importable from the package entry:
CallbackDataParams- the per-item params object passed tolabel.formatter, and to each element of the array a series-groupedtooltip.formatterreceives.TopLevelFormatterParams- the exact type of theparamsargument oftooltip.formatter(CallbackDataParams | CallbackDataParams[]).Why?
Today people either type
paramsasanyand lose all checking, copy the interface by hand, or import from an internal path such asecharts/types/dist/shared.js. All of those break as soon as the internals move. With this change the supported usage is:The aliases
DefaultLabelFormatterCallbackParamsandTooltipComponentFormatterCallbackParamsalready existed on the ESM types entry, but the base names were not exported and neither name reached the CJS types entry. This re-exports the base names from the core export, which feeds both entries, so the types resolve regardless of module resolution mode. The change is type-only, with no runtime output.Closes #14277