apprev/components-jsx/runtime.ts
2025-05-23 03:19:00 -04:00

20 lines
382 B
TypeScript

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);
}