-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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: improve preact compat types adding a few missing @types/react used by styled-components #4271
Conversation
…d by styled-components
@@ -55,6 +56,8 @@ declare namespace React { | |||
export import cloneElement = preact.cloneElement; | |||
export import ComponentProps = preact.ComponentProps; | |||
export import ReactNode = preact.ComponentChild; | |||
export import ReactElement = preact.VNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VNode
seemed to be the closest thing in preact to ReactElement from what I could gather, but this might be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems right, VNode
looks to cover all the same properties (and a couple more).
@@ -169,6 +172,12 @@ declare namespace React { | |||
| MutableRefObject<T | null> | |||
| null; | |||
|
|||
export type ComponentPropsWithRef< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I mixed the @types/react implementation with preact's one for ComponentProps.
I think this makes sense, but I have some doubts, so would be great if someone with more understanding of the preact side can confirm 👼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this cause issue #4293.
Hello preact team!
Recently, we ran into some TypeScript issues in a project where we use preact with styled-components.
Looking a bit more in depth at the issues, they seemed to stem from a few missing types from @types/react, this PR aims to add those types in.
With those changes, we got a project with preact+styled-components working correctly (PS: this is a good first sign, but the project isn't that huge, so there could be things that don't work in 100% of the situations)
It would likely fix this issue