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
[styled] Convert implicit styleProps to explicit #26461
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly should we test. We removed these props from the native typings, so they behave as any other props. Testing whether they can be optional or not doesn't make sense to me. Can you point out to specific test case that makes sense? |
I was thinking of something in this order, to complement the existing tests. I'm not sure if it really makes a difference. diff --git a/packages/material-ui/src/styles/experimentalStyled.spec.tsx b/packages/material-ui/src/styles/experimentalStyled.spec.tsx
index 84fc2756f3..1ded15d117 100644
--- a/packages/material-ui/src/styles/experimentalStyled.spec.tsx
+++ b/packages/material-ui/src/styles/experimentalStyled.spec.tsx
@@ -1,5 +1,6 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@material-ui/core/styles';
const Box = styled('div')(({ theme }) => ({
color: theme.palette.primary.main,
@@ -26,3 +27,21 @@ const StyledToolbar = styled('div')(({ theme }) => ({
const StyledSpan = styled('span')(({ theme }) => ({
...theme.typography.body1,
}));
+
+const WithProps = styled('span')<{ styleProps: { foo: string } }>(({ styleProps }) => {
+ return { color: styleProps.foo };
+});
+
+<WithProps styleProps={{ foo: 'bar' }} />;
+
+// @ts-expect-error styleProps doesn't exist
+const MissingOption = styled('span')(({ styleProps }) => {
+ return { height: 1 };
+});
+
+const MissingProperty = styled('span')<{ styleProps: { inner: boolean } }>(({ styleProps }) => {
+ return { height: 1 };
+});
+
+// @ts-expect-error missing inner property
+<MissingProperty styleProps={{}} />; |
I don't think it will bring much value, as it is nothing specific to the |
@mnajdova Yeah, my point is that we don't have a test for this TypeScript first argument to add new props (it's not specific to |
BREAKING CHANGE
A wildcard
styleProps
is no longer being added by default byexperimentalStyled()
. You need to specify them by yourself, as any other props:Closes #26410