diff --git a/src/js/globals.d.ts b/src/js/globals.d.ts index 8d62ff0f..2caea804 100644 --- a/src/js/globals.d.ts +++ b/src/js/globals.d.ts @@ -158,8 +158,8 @@ declare namespace JSX { */ type IntrinsicElements = { [K in keyof HTMLElementTagNameMap]: { - children?: Node | Node[]; - [k: string]: Node | Node[] | string | number | boolean; + children?: JSXNode | JSXNode[]; + [k: string]: JSXNode | JSXNode[] | string | number | boolean; }; }; /** @@ -173,14 +173,16 @@ declare namespace JSX { * An attributes object. */ type Props = { [k: string]: unknown }; + /** * A functional component requiring attributes to match `T`. */ type Component = { (props: T): Element; }; + /** * A child of a JSX element. */ - type Node = Element | string | boolean | null | undefined; + type JSXNode = Node | string | boolean | null | undefined; } diff --git a/src/js/jsx-runtime.ts b/src/js/jsx-runtime.ts index be285029..1db25d1f 100644 --- a/src/js/jsx-runtime.ts +++ b/src/js/jsx-runtime.ts @@ -1,4 +1,4 @@ -function isDisplayed(node: JSX.Node): node is Exclude { +function isDisplayed(node: JSX.JSXNode): node is Exclude { return typeof node !== "boolean" && node != null; } @@ -27,7 +27,7 @@ function jsx( } throw new TypeError("JSX element attribute assigned invalid type"); }); - element.append(...([children].flat(Infinity) as JSX.Node[]).filter(isDisplayed)); + element.append(...([children].flat(Infinity) as JSX.JSXNode[]).filter(isDisplayed)); return element; } @@ -38,4 +38,4 @@ function jsx( const Fragment = (props: JSX.Props) => props.children as JSX.Element; // jsxs is used when there are multiple children -export { jsx, jsx as jsxs, Fragment }; +export { Fragment, jsx, jsx as jsxs };