ts: improve preact compat types adding a few missing @types/react used by styled-components#4271
Merged
JoviDeCroock merged 1 commit intopreactjs:mainfrom Feb 2, 2024
Merged
Conversation
…d by styled-components
jduthon
commented
Feb 2, 2024
| export import cloneElement = preact.cloneElement; | ||
| export import ComponentProps = preact.ComponentProps; | ||
| export import ReactNode = preact.ComponentChild; | ||
| export import ReactElement = preact.VNode; |
Contributor
Author
There was a problem hiding this comment.
VNode seemed to be the closest thing in preact to ReactElement from what I could gather, but this might be wrong.
Member
There was a problem hiding this comment.
Seems right, VNode looks to cover all the same properties (and a couple more).
jduthon
commented
Feb 2, 2024
| | MutableRefObject<T | null> | ||
| | null; | ||
|
|
||
| export type ComponentPropsWithRef< |
Contributor
Author
There was a problem hiding this comment.
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 👼
rschristian
approved these changes
Feb 2, 2024
JoviDeCroock
approved these changes
Feb 2, 2024
Merged
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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