Skip to content
19 changes: 17 additions & 2 deletions compat/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as _hooks from '../../hooks';
import * as preact from '../../src';
import { JSXInternal } from '../../src/jsx';
import * as JSXInternal from './jsx';
import * as _Suspense from './suspense';
import * as _SuspenseList from './suspense-list'

Expand Down Expand Up @@ -32,9 +32,23 @@ declare namespace React {
export import useErrorBoundary = _hooks.useErrorBoundary

// Preact Defaults
export import Component = preact.Component;
export interface Component<P = {}, S = {}, SS = any> extends preact.Component<P, S> {}
export abstract class Component<P, S> extends preact.Component<P, S> {}
export interface ReactElement<P = {}, S = any> extends preact.VNode<P> {}
export import ComponentClass = preact.ComponentClass;
export import ComponentType = preact.ComponentType;
export import JSXElementConstructor = preact.AnyComponent;
export import Attributes = preact.Attributes;
export import ClassAttributes = preact.ClassAttributes;
export import Context = preact.Context;
export import Provider = preact.Provider;
export import ReactNode = preact.ComponentChildren;
export import ComponentPropsWithRef = preact.RenderableProps;
export type CSSProperties = string | {[key: string]: string | number};
export interface AllHTMLAttributes<T> extends JSX.HTMLAttributes {}
export import FunctionComponent = preact.FunctionComponent;
export import FC = preact.FunctionComponent;
export import SFC = preact.FunctionComponent;
export import createContext = preact.createContext;
export import createRef = preact.createRef;
export import Fragment = preact.Fragment;
Expand Down Expand Up @@ -122,4 +136,5 @@ declare namespace React {
only: (children: preact.ComponentChildren) => preact.ComponentChild;
toArray: (children: preact.ComponentChildren) => preact.VNode<{}>[];
};

}
4 changes: 4 additions & 0 deletions compat/src/jsx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { JSXInternal } from '../../src/jsx';

export = JSXInternal;
export as namespace JSX;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this broke typescript before

preactjs/preact-cli#1030

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what way? I skimmed through the referenced issue but did not understand how this breaks typescript. This file declares the JSX namespace, without which, typescript does not process jsx. This is also the same way react itself exports the JSX namespace