11/**
2- * @typedef {import('xast').Root } Root
32 * @typedef {import('xast').Element } Element
3+ * @typedef {import('xast').Nodes } Nodes
4+ * @typedef {import('xast').Root } Root
45 */
56
67/**
7- * @typedef {Root['children'][number] } Content
8- * @typedef {Content | Root } Node
9- * Any concrete `xast` node.
10- *
11- * @typedef {Root | Element } Result
8+ * @typedef {Element | Root } Result
129 * Result from a `x` call.
1310 *
14- * @typedef {string | number | boolean | null | undefined } Value
11+ * @typedef {boolean | number | string | null | undefined } Value
1512 * Attribute value
13+ *
1614 * @typedef {{[attribute: string]: Value} } Attributes
1715 * Acceptable value for element properties.
1816 *
19- * @typedef {string | number | null | undefined } PrimitiveChild
17+ * @typedef {boolean | number | string | null | undefined } PrimitiveChild
2018 * Primitive children, either ignored (nullish), or turned into text nodes.
21- * @typedef {Array<Node | PrimitiveChild> } ArrayChild
19+ * @typedef {Array<Nodes | PrimitiveChild> } ArrayChild
2220 * List of children.
23- * @typedef {Node | PrimitiveChild | ArrayChild } Child
21+ * @typedef {Nodes | PrimitiveChild | ArrayChild } Child
2422 * Acceptable child value.
25- *
23+ */
24+
25+ // Define JSX.
26+
27+ /**
2628 * @typedef {import('./jsx-classic.js').Element } x.JSX.Element
2729 * @typedef {import('./jsx-classic.js').IntrinsicAttributes } x.JSX.IntrinsicAttributes
2830 * @typedef {import('./jsx-classic.js').IntrinsicElements } x.JSX.IntrinsicElements
3941 * When string, an `Element` is built.
4042 * When nullish, a `Root` is built instead.
4143 * @param attributes
42- * Attributes of the element.
44+ * Attributes of the element or first child .
4345 * @param children
4446 * Children of the node.
4547 * @returns
4648 * `Element` or `Root`.
4749 */
4850export const x =
51+ // Note: not yet possible to use the spread `...children` in JSDoc overloads.
4952 /**
5053 * @type {{
5154 * (): Root
@@ -68,7 +71,7 @@ export const x =
6871
6972 if ( name === undefined || name === null ) {
7073 node = { type : 'root' , children : [ ] }
71- // @ts -expect-error Root builder doesn’t accept attributes.
74+ // @ts -expect-error: Root builder doesn’t accept attributes.
7275 children . unshift ( attributes )
7376 } else if ( typeof name === 'string' ) {
7477 node = { type : 'element' , name, attributes : { } , children : [ ] }
@@ -111,7 +114,7 @@ export const x =
111114 * List of nodes.
112115 * @param {Child } value
113116 * Child.
114- * @returns {void }
117+ * @returns {undefined }
115118 * Nothing.
116119 */
117120function addChild ( nodes , value ) {
0 commit comments