From ed788323194c302ab8dcf15098ab385212cf3455 Mon Sep 17 00:00:00 2001 From: Ian Obermiller Date: Thu, 21 Dec 2023 07:28:16 -0500 Subject: [PATCH 1/3] Add ComponentType to preact/compat Add the `ComponentType` type that represents a class or function component with optional props to mirror the same type in `@types/react`: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0818c3f7de545c6b6431e9745dd9910618bba918/types/react/index.d.ts#L43 --- compat/src/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/src/index.d.ts b/compat/src/index.d.ts index 6cbf585bfe..a09be91916 100644 --- a/compat/src/index.d.ts +++ b/compat/src/index.d.ts @@ -46,6 +46,7 @@ declare namespace React { export import RefObject = preact.RefObject; export import Component = preact.Component; export import FunctionComponent = preact.FunctionComponent; + export type ComponentType = Component | FunctionComponent; export import FC = preact.FunctionComponent; export import createContext = preact.createContext; export import createRef = preact.createRef; From c6d106250f5408fd5797dc1fadb76466f76393b2 Mon Sep 17 00:00:00 2001 From: Ian Obermiller Date: Fri, 22 Dec 2023 14:36:18 -0500 Subject: [PATCH 2/3] Export existing type instad Co-authored-by: Ryan Christian <33403762+rschristian@users.noreply.github.com> --- compat/src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/src/index.d.ts b/compat/src/index.d.ts index a09be91916..a8ab4fb0fe 100644 --- a/compat/src/index.d.ts +++ b/compat/src/index.d.ts @@ -46,7 +46,7 @@ declare namespace React { export import RefObject = preact.RefObject; export import Component = preact.Component; export import FunctionComponent = preact.FunctionComponent; - export type ComponentType = Component | FunctionComponent; + export import preact.ComponentType; export import FC = preact.FunctionComponent; export import createContext = preact.createContext; export import createRef = preact.createRef; From be2ca05b8192f41eb008e6768a6dd21cc27abb8b Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Fri, 22 Dec 2023 13:42:37 -0600 Subject: [PATCH 3/3] Update index.d.ts --- compat/src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/src/index.d.ts b/compat/src/index.d.ts index a8ab4fb0fe..028542607c 100644 --- a/compat/src/index.d.ts +++ b/compat/src/index.d.ts @@ -46,7 +46,7 @@ declare namespace React { export import RefObject = preact.RefObject; export import Component = preact.Component; export import FunctionComponent = preact.FunctionComponent; - export import preact.ComponentType; + export import ComponentType = preact.ComponentType; export import FC = preact.FunctionComponent; export import createContext = preact.createContext; export import createRef = preact.createRef;