@expressive/react
Version:
Use classes to define state in React!
43 lines (42 loc) • 2.25 kB
TypeScript
import { State } from "@expressive/state";
import React, { Fragment } from "react";
//#region src/jsx-runtime.d.ts
type Reserved = keyof State | 'render' | 'fallback';
type StateProps<T extends State> = { [K in Exclude<keyof T, Reserved>]?: T[K] };
type ComponentProps<T extends State> = StateProps<T> & {
is?: (instance: T) => void;
fallback?: React.ReactNode;
};
type ValidProps<T extends State> = StateProps<T> & {
is?: never;
get?: never;
set?: never;
};
interface AsComponent extends State {
render?(props: ValidProps<this>, self: this): React.ReactNode;
fallback?: React.ReactNode;
}
type Props<T extends State> = T extends {
render(props: infer P, self: any): any;
} ? ComponentProps<T> & Omit<P, keyof AsComponent> : ComponentProps<T> & {
children?: React.ReactNode;
};
declare namespace JSX {
type ElementType = State.Extends<AsComponent> | React.JSX.ElementType | ((props: {}, ref?: any) => void);
type LibraryManagedAttributes<C, P> = C extends (new (...args: any[]) => {
props: infer U;
}) ? U : C extends State.Extends<infer U> ? Props<U> : React.JSX.LibraryManagedAttributes<C, P>;
interface Element extends React.JSX.Element {}
interface ElementClass extends React.JSX.ElementClass {}
interface ElementAttributesProperty {}
interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {}
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
}
declare function patch(this: (type: React.ElementType, ...args: any[]) => React.ReactElement, type: React.ElementType | State.Type, ...args: any[]): React.ReactElement;
declare const jsx: (type: React.ElementType<any, keyof React.JSX.IntrinsicElements> | State.Type<State>, ...args: any[]) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
declare const jsxs: (type: React.ElementType<any, keyof React.JSX.IntrinsicElements> | State.Type<State>, ...args: any[]) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
//#endregion
export { Fragment, JSX, jsx, jsxs, patch };
//# sourceMappingURL=jsx-runtime.d.ts.map