-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ declare namespace React { | |
export import Component = preact.Component; | ||
export import FunctionComponent = preact.FunctionComponent; | ||
export import ComponentType = preact.ComponentType; | ||
export import ComponentClass = preact.ComponentClass; | ||
export import FC = preact.FunctionComponent; | ||
export import createContext = preact.createContext; | ||
export import createRef = preact.createRef; | ||
|
@@ -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; | ||
export import Consumer = preact.Consumer; | ||
|
||
// Suspense | ||
export import Suspense = _Suspense.Suspense; | ||
|
@@ -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 commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this cause issue #4293. |
||
C extends ComponentType<any> | keyof JSXInternal.IntrinsicElements | ||
> = C extends (new(props: infer P) => Component<any, any>) | ||
? PropsWithoutRef<P> & RefAttributes<InstanceType<C>> | ||
: ComponentProps<C>; | ||
|
||
export function flushSync<R>(fn: () => R): R; | ||
export function flushSync<A, R>(fn: (a: A) => R, a: A): R; | ||
|
||
|
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).