apprev/components-jsx/runtime.ts
2025-05-22 19:47:48 -04:00

22 lines
410 B
TypeScript

import { br } from "./br";
export const Fragment = Symbol("ComponentsJsx.Fragment");
type FunctionComponent = (props: any) => any;
export function createElement(
type: typeof Fragment | FunctionComponent,
props: any,
...children: any[]
) {
if (type === Fragment) {
return children;
}
props ??= {};
props.children = children;
// @ts-ignore
if (type === "br") return "\n";
return type(props);
}