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
SxProps
Type for sx
property.
#27564
Comments
You can use: import { SxProps } from '@material-ui/system'; |
Thanks for the feedback. It's not clear from the current description what the problem is. Please don't just discard the issue template you're prompted with but fill it out. Specifically, actual behavior and expected behavior. |
Unfortunately, this solution does not work. I get the following error even after adding |
Okay sounds good. Sorry about that. Updated. |
@mahyarmirrashed please share a codesandbox illustrating the issue. The import proposed in #27564 (comment) should work. |
We are using airbnb and other strict rules according to type safety, and we are using |
Issue solved. This last comment about the TypeScript version is key. Solution:
Future steps:Perhaps adding this as a caveat or note somewhere either in |
How do I import SxProps with the new @mui import? |
import { SxProps } from '@mui/system'; |
this doesn't work anymore. Now you need to import from |
This helped me, thank you. Can I ask how you knew how to do this? I've found that to look up types for libraries like MUI, I have to google until I find an issue like this. I tried looking at the docs and of course following component definitions through the code itself, but in this case for example failed to find a type definition for SX or how to import it. How did you know? |
For me this import seems like working: |
Try: import type { SxProps } from '@mui/material'; |
it's worrked |
Actual Behaviour:
Accessing the type definition for the
sx
prop is convoluted. From my gathering, the only way is to useimport { SxProps } from '@material-ui/system/styleFunctionSx/styleFunctionSx';
.Expected Behaviour:
Ideally, a solution like the one @rajzik suggested (
import { SxProps } from '@material-ui/system';
). Unfortunately, at the moment, this potential solution results inModule '"@material-ui/system"' has no exported member 'SxProps'.ts(2305)
.Background:
There are several factors that lead to this issue:
^4.0.3
)^7.32.0
)any
type in TypeScript code.Code:
The text was updated successfully, but these errors were encountered: