export type ReactElement = { type: string | Function props: Record & { children?: ReactNode[] } } export type ReactNode = ReactElement | string | number | null | undefined | ReactNode[] export type FC

> = (props: P) => ReactElement export function createElement( type: string | Function, props: Record | null, ...children: ReactNode[] ): ReactElement { const flatChildren = children.flat() return { type, props: { ...props, children: flatChildren.length === 1 ? (flatChildren as ReactNode[]) : flatChildren.length > 0 ? flatChildren : undefined } } } export default { createElement }