-
Notifications
You must be signed in to change notification settings - Fork 671
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
TS Error: Property 'sx' does not exist on type 'HTMLAttributes' when using Preact #633
Comments
Not sure it already supports Preact 🤔
quote from theme-ui.com/guides/jsx-pragma Edit: Just remembered that I use theme-ui along |
Yes, this library is only intended for use with React and Preact may or may not work. You can use some of the underlying utilities that theme-ui is built with (like |
@likidu You can alias To let TypeScript know what I'd try declaration merging of something along these lines /** @jsx jsx */
import { jsx, SxStyleProp } from 'theme-ui';
declare global {
namespace preact {
interface PreactDOMAttributes {
sx: SxStyleProp
}
}
} |
@hasparus Can we close? |
Describe the bug
I am trying to use theme-ui with a Preact app with Typescript. When I am using the
sx
prop, there was Typescript error prompted in the editor.To Reproduce
Steps to reproduce the behavior:
I am using VS Code with ESlint and Prettier extensions. A simple button.tsx:
The code can be compiled successfully with the right CSS applied to it. But it's with the VS Code, it shows the
sx
prop has error:And one more side effect here is I have set the pragma as
h
which is using the Preact. But to usesx
from theme-ui, it requires to add/** @jsx jsx */
at the beginning of the module which overlaps the Preact one. Then it also gives a warning:Expected behavior
There should be none errors shown in the editor when using theme-ui with Preact in Typescript.
Screenshots
Additional context
Npm package versions:
theme-ui
: 0.3.1preact
: 10.0.0The text was updated successfully, but these errors were encountered: