Skip to content

Commit a3f7c33

Browse files
authored
ts: improve preact compat types adding a few missing @types/react used by styled-components (#4271)
1 parent 49433b3 commit a3f7c33

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compat/src/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ declare namespace React {
4747
export import Component = preact.Component;
4848
export import FunctionComponent = preact.FunctionComponent;
4949
export import ComponentType = preact.ComponentType;
50+
export import ComponentClass = preact.ComponentClass;
5051
export import FC = preact.FunctionComponent;
5152
export import createContext = preact.createContext;
5253
export import createRef = preact.createRef;
@@ -55,6 +56,8 @@ declare namespace React {
5556
export import cloneElement = preact.cloneElement;
5657
export import ComponentProps = preact.ComponentProps;
5758
export import ReactNode = preact.ComponentChild;
59+
export import ReactElement = preact.VNode;
60+
export import Consumer = preact.Consumer;
5861

5962
// Suspense
6063
export import Suspense = _Suspense.Suspense;
@@ -169,6 +172,12 @@ declare namespace React {
169172
| MutableRefObject<T | null>
170173
| null;
171174

175+
export type ComponentPropsWithRef<
176+
C extends ComponentType<any> | keyof JSXInternal.IntrinsicElements
177+
> = C extends (new(props: infer P) => Component<any, any>)
178+
? PropsWithoutRef<P> & RefAttributes<InstanceType<C>>
179+
: ComponentProps<C>;
180+
172181
export function flushSync<R>(fn: () => R): R;
173182
export function flushSync<A, R>(fn: (a: A) => R, a: A): R;
174183

0 commit comments

Comments
 (0)