Skip to content
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

Invalid strings are available for sx property names #33794

Closed
2 tasks done
ossan-engineer opened this issue Aug 4, 2022 · 2 comments
Closed
2 tasks done

Invalid strings are available for sx property names #33794

ossan-engineer opened this issue Aug 4, 2022 · 2 comments
Labels
out of scope The problem looks valid but we won't fix it (maybe we will revisit it in the future) package: system Specific to @mui/system typescript

Comments

@ossan-engineer
Copy link
Contributor

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

const CustomButton = () => (
  <Button
    sx={{
      mt: 1,
      lm: 1, // ml typo but compiled without type error
    }} 
  />
)

↓ compiled styles

.css-hash {
    margin-top: 8px;
    lm: 1px; // invalid property
}

Expected behavior πŸ€”

const CustomButton = () => (
  <Button
    sx={{
      mt: 1,
      lm: 1, // want to get a type error here
    }} 
  />
)

Steps to reproduce πŸ•Ή

https://codesandbox.io/s/jovial-glitter-kt9uvc?file=/demo.tsx

Context πŸ”¦

No response

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@ossan-engineer ossan-engineer added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 4, 2022
@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Aug 10, 2022

Thanks for reporting! Look like a bug indeed.

I think this happens after we started supporting CSS variable types and CSS variable types with nested selectors (#31163) in the sx prop.

We can use TypeScript template literals in index signatures to fix this. But then this feature is available since TypeScript 4.4+ . It may break for developers using TypeScript version less than 4.4 with Material-UI. In MUI, we support minimum version till TypeScript 3.5.

I will create a PR and see what the MUI team says.

Note: This will only prevent a type error, but styles will still compile.

@ZeeshanTamboli ZeeshanTamboli added bug πŸ› Something doesn't work typescript package: system Specific to @mui/system and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 10, 2022
@siriwatknp siriwatknp added out of scope The problem looks valid but we won't fix it (maybe we will revisit it in the future) and removed bug πŸ› Something doesn't work labels Oct 26, 2022
@siriwatknp
Copy link
Member

Based on #33879 (comment), I marked this as "out of scope".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
out of scope The problem looks valid but we won't fix it (maybe we will revisit it in the future) package: system Specific to @mui/system typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants