export as namespace preact;
import { JSXInternal } from './jsx';
export import JSX = JSXInternal;
//
// Preact Virtual DOM
// -----------------------------------
export interface VNode
{
type: ComponentType
| string;
props: P & { children: ComponentChildren };
key: Key;
/**
* ref is not guaranteed by React.ReactElement, for compatibility reasons
* with popular react libs we define it as optional too
*/
ref?: Ref | null;
/**
* The time this `vnode` started rendering. Will only be set when
* the devtools are attached.
* Default value: `0`
*/
startTime?: number;
/**
* The time that the rendering of this `vnode` was completed. Will only be
* set when the devtools are attached.
* Default value: `-1`
*/
endTime?: number;
}
//
// Preact Component interface
// -----------------------------------
export type Key = string | number | any;
export type RefObject = { current: T | null };
export type RefCallback = (instance: T | null) => void;
export type Ref = RefObject | RefCallback;
export type ComponentChild =
| VNode
| object
| string
| number
| bigint
| boolean
| null
| undefined;
export type ComponentChildren = ComponentChild[] | ComponentChild;
export interface Attributes {
key?: Key;
jsx?: boolean;
}
export interface ClassAttributes extends Attributes {
ref?: Ref;
}
export interface PreactDOMAttributes {
children?: ComponentChildren;
dangerouslySetInnerHTML?: {
__html: string;
};
}
export type RenderableProps
= P &
Readonly }>;
export type ComponentType
= ComponentClass
| FunctionComponent
;
export type ComponentFactory
= ComponentType
;
export type ComponentProps<
C extends ComponentType | keyof JSXInternal.IntrinsicElements
> = C extends ComponentType
? P
: C extends keyof JSXInternal.IntrinsicElements
? JSXInternal.IntrinsicElements[C]
: never;
export interface FunctionComponent
,
previousState: Readonly,
snapshot: any
): void;
componentDidCatch?(error: any, errorInfo: any): void;
}
export abstract class Component
{
constructor(props?: P, context?: any);
static displayName?: string;
static defaultProps?: any;
static contextType?: Context;
// Static members cannot reference class type parameters. This is not
// supported in TypeScript. Reusing the same type arguments from `Component`
// will lead to an impossible state where one cannot satisfy the type
// constraint under no circumstances, see #1356.In general type arguments
// seem to be a bit buggy and not supported well at the time of this
// writing with TS 3.3.3333.
static getDerivedStateFromProps?(
props: Readonly