{"record":{"id":"4dc1c790f929cf7b","repo":"ianstormtaylor/slate","slug":"unexpected-hyperscript-child-object-child","errorCode":null,"errorMessage":"Unexpected hyperscript child object: ${child}","messagePattern":"Unexpected hyperscript child object: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/slate-hyperscript/src/creators.ts","lineNumber":69,"sourceCode":"    } else if (Element.isElement(child)) {\n      nodes.push(child)\n    } else if (child instanceof Token) {\n      let n = nodes[nodes.length - 1]\n\n      if (!Text.isText(n)) {\n        addChild('')\n        n = nodes[nodes.length - 1] as Text\n      }\n\n      if (child instanceof AnchorToken) {\n        addAnchorToken(n, child)\n      } else if (child instanceof FocusToken) {\n        addFocusToken(n, child)\n      } else if (child instanceof PointToken) {\n        addPointToken(n, child)\n      }\n    } else {\n      throw new Error(`Unexpected hyperscript child object: ${child}`)\n    }\n  }\n\n  for (const child of children.flat(Infinity)) {\n    addChild(child)\n  }\n\n  return nodes\n}\n\n/**\n * Create an anchor token.\n */\n\nexport function createAnchor(\n  tagName: string,\n  attributes: { [key: string]: any },\n  children: any[]","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/ianstormtaylor/slate/blob/72a37c701e5da4bb13a305d416d9c070d19d3a45/packages/slate-hyperscript/src/creators.ts#L51-L87","documentation":"Thrown by hyperscript's addChild when a child value passed into an element creator is of an unrecognized type — not a string, number, Slate node, Token, or JSX element the creator knows how to handle.","triggerScenarios":"Passing null/undefined, booleans, plain objects, or arbitrary class instances as children in slate-hyperscript JSX, e.g. <element>{null}</element> with certain creator versions or a custom creators object that doesn't handle a type.","commonSituations":"Conditionally rendering children that evaluate to unexpected values in hyperscript tests; spreading arrays containing undefined; custom creators replacing default handlers.","solutions":["Filter children: remove null/undefined/booleans before passing to hyperscript tags","Ensure children are strings, numbers, element/text tags, or token tags (<anchor/>, <focus/>, <cursor/>)","Check the custom creators object if you replaced default child handling"],"exampleFix":"// before\n<element>{cond ? <text>hi</text> : null}</element>\n// after\n<element>{cond ? <text>hi</text> : <text />}</element>","handlingStrategy":"validation","validationCode":"const kids = children.flat(Infinity).filter(\n  c => c != null && typeof c !== 'boolean'\n)\n// pass kids to hyperscript tags","typeGuard":"const isHyperscriptChild = (c: any): boolean =>\n  typeof c === 'string' ||\n  typeof c === 'number' ||\n  (typeof c === 'object' && c !== null && ('text' in c || 'children' in c || 'type' in c))","tryCatchPattern":"null","preventionTips":["Filter null/undefined/booleans from children arrays","Keep children limited to strings, numbers, and node/token tags","Avoid arbitrary object instances as hyperscript children"],"tags":["slate","hyperscript","jsx","children"],"backgroundTag":"invalid-hyperscript-child","analyzedSha":"72a37c701e5da4bb13a305d416d9c070d19d3a45","analyzedAt":"2026-08-27T23:04:51.145Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}