TS: Property 'sx' does not exist on type 'SVGProps<SVGRectElement>'
See original GitHub issueDescribe the bug
I get a TypeScript error when I try to use the sx
prop on an SVG element claiming that Property 'sx' does not exist on type 'SVGProps<SVGRectElement>'
, yet it works just fine anyway.
To Reproduce
/** @jsx jsx */
import React from 'react';
import { jsx } from 'theme-ui';
const Foo = () => <rect sx={{ fill: 'papayawhip' }} />
Expected behavior
I expect sx
to be a valid prop on SVG elements or for sx
to fail on SVG elements. (Would much rather the former since it works anyway 🙂.)
Screenshots N/A
Additional context N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to declare types of props of SVG component? [React ...
I've been facing this problem, and this solution worked fine for me: declare module "*.svg" { import { ReactElement, SVGProps } from "react" ......
Read more >The `sx` Prop - Theme UI
The sx Prop. The sx prop lets you style elements inline, using values from your theme. To use the sx prop, add the...
Read more >Troubleshooting - Material UI - MUI
[Types] Property "palette", "spacing" does not exist on type 'DefaultTheme'. This error arises because makeStyles is now exported from the @mui/styles package, ...
Read more ><rect> - SVG: Scalable Vector Graphics - MDN Web Docs
The <rect> element is a basic SVG shape that draws rectangles, defined by their position, width, and height. The rectangles may have their...
Read more >Why I am getting typescript error when trying to use Material-ui ...
Property 'alt' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Avatar> & Readonly<AvatarProps> & Readonly<{ children ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s a CodeSandbox demo https://codesandbox.io/s/theme-ui-rect-fg6g0.
Theme UI 0.3.1 is written fully in JavaScript. You can notice that types appear on hover in the demo, because @types/theme-ui is installed automatically by the IDE.
When you’re using TypeScript, you need to install
@types
libs yourself.Does installing
@types/theme-ui
solve the problem? If not, I’d like to help figure it out.Okay, this is a bit weird. I doublechecked in DefinitelyTyped, and the way both versions register
sx
prop is exactly the same.There are still some rough edges regarding TypeScript in 0.4.0-rc.1. Feel free to ping me here if you encounter any problems.