-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[charts] Fix TS performances #12921
Comments
Copy paste of my message on Slack: For the Bar Chart issue, I think I was able to fix it by simplifying the type of the bar slot. --- a/packages/x-charts/src/BarChart/BarElement.tsx
+++ b/packages/x-charts/src/BarChart/BarElement.tsx
@@ -73,7 +73,7 @@ export interface BarElementSlots {
* The component that renders the bar.
* @default BarElementPath
*/
- bar?: React.JSXElementConstructor<BarProps>;
+ bar?: React.ElementType; If we do want to keep this typing then we can assure TS that BarElementPath has the right value: --- a/packages/x-charts/src/BarChart/BarElement.tsx
+++ b/packages/x-charts/src/BarChart/BarElement.tsx
@@ -60,7 +60,7 @@ export const BarElementPath = styled(animated.rect, {
: ownerState.color,
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
opacity: (ownerState.isFaded && 0.3) || 1,
-}));
+})) as React.JSXElementConstructor<BarProps>; With both fixes, A few side notes: Is there a reason why we use |
Not that much, I picked it from the pickers' implementation |
@alexfauquette: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
In #12920 the Typescript usage for pickers has been improved. Remain the
AnimatedArea
andBarElement
to improve on chartsSearch keywords: TypeScript
The text was updated successfully, but these errors were encountered: