question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TS reports sx prop as an error on basic HTML elements

See original GitHub issue

Describe the bug

Whenever I use the sx prop with a basic HTML element (e.g., <div>), TS reports it as an error: Property 'sx' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.

Stranger still, IntelliSense seems to pick up the correct definitions from @types/theme-ui:

Ekran Resmi 2020-09-14 ÖS 1 23 19

This behavior only occurs with basic HTML elements. Using the sx prop on React components is fine.

To Reproduce

I’m not sure how to reproduce the problem, it’s always been an issue for my project. I’ve chosen to ignore it because I use Babel for TS compilation which strips out all types, so it’s not a blocker. However, it’s highly annoying.

Expected behavior

Using the sx prop with an HTML element just works.

Screenshots

See above.

Additional context

I do have @types/theme-ui installed, so this shouldn’t be a problem.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
atanasstercommented, Oct 29, 2020

Thanks a lot, yes pls create a new issue (and if you fel like it, maybe a PR, or we could work both on it?) - the sx prop with your theme types - not sure how we can make that in a compatible way - but we can discuss it in the new issue.

The current one I still think unless we can get a repro should close, just too much backlog noise

0reactions
ersinakincicommented, Oct 29, 2020

Yes, exactly, something like that. There would also need to be some way to hook up MyTheme to sx, etc.

I’m personally OK with closing the current issue, but it appears that others are facing it, too. I’ll create a new issue for the generics.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TS reports sx prop as an error on basic HTML elements
Whenever I use the sx prop with a basic HTML element (e.g., <div> ), TS reports it as an error: Property 'sx' does...
Read more >
MUI 5 SX Typescript error when spreading values in prop
I need some help with this typescript error with MUI sx prop. When I try to combined or spreed sx values into an...
Read more >
React-admin - Theming
This sx prop is kind of like React's style prop, but it's more powerful. ... The basic syntax is styled(Component)(styles) => Component (where...
Read more >
@mui/system | Yarn - Package Manager
CSS utilities for rapidly laying out custom designs. Installation. Install the package in your project directory with: // with npm npm install @mui/system...
Read more >
Configuring Jest
To read TypeScript configuration files Jest requires ts-node . ... By default, Jest runs all tests and produces all errors into the console ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found