[charts] Remove default generic of item identifiers#21182
[charts] Remove default generic of item identifiers#21182alexfauquette wants to merge 9 commits intomui:masterfrom
Conversation
|
Deploy preview: https://deploy-preview-21182--material-ui-x.netlify.app/ Updated pages: Bundle size report
|
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes |
JCQuintas
left a comment
There was a problem hiding this comment.
Not sure this is necessary. Can't we have the initial value be "anytype", and users trim it down by either SeriesItemIdentifier<'line'> or
const item = ourOutputItem
if (item.type !== 'heatmap') {
// ignore
}
// do something|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
That's kind of already the case For callbackIf you look at the definition of the So if the export type ChartDataProviderProProps<
TSeries extends ChartSeriesType = ChartSeriesType,
TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<TSeries>,
> = ChartDataProviderProps<TSeries, TSignatures> &
ChartProviderProps<TSeries, TSignatures>['pluginParams'] & {
/**
* Slots to customize charts' components.
*/
slots?: Partial<ChartDataProviderProSlots>;
/**
* The props for the slots.
*/
slotProps?: Partial<ChartDataProviderProSlotProps>;
};For user stateHere it changes a bit, because it forces the user to specify which series type they plan to store. Why doing itI got multiple TS issue that were hard to understand because sometime the generic argument is provided, sometime not, so it defaultize to all series type. Leading to error like "The union does not match with this other union" Removing the default value forces us to correctly type pass the generic or explicitly say "this can be any series type" |
|
The benefits seem to outweigh the drawbacks, so we can roll with it :) |
Extracted from #21161
The idea is that item identifier does not make that much sense. For now most of the identifier are the same
{ type, seriesId, dataIndex }but with heatmap will be{ type, seriesId, xIndex, yIndex }or the sankey identifierNot sure about how to document that "breaking change" or document it