ianstormtaylor/slate · error · Error

No hyperscript creator found for tag: <${tagName}>

Error message

No hyperscript creator found for tag: <${tagName}>

What it means

Thrown by the hyperscript jsx() function when the requested tag name has no registered creator. The creators object (defaults plus custom elements) defines which tags are usable; anything else is rejected.

Source

Thrown at packages/slate-hyperscript/src/hyperscript.ts:83

  const jsx = createFactory(creators)
  return jsx
}

/**
 * Create a Slate hyperscript function with `options`.
 */

const createFactory = <T extends HyperscriptCreators>(creators: T) => {
  const jsx = <S extends keyof T & string>(
    tagName: S,
    attributes?: Object,
    ...children: any[]
  ): ReturnType<T[S]> => {
    const creator = creators[tagName]

    if (!creator) {
      throw new Error(`No hyperscript creator found for tag: <${tagName}>`)
    }

    if (attributes == null) {
      attributes = {}
    }

    if (!isObject(attributes)) {
      children = [attributes].concat(children)
      attributes = {}
    }

    children = children.filter(child => Boolean(child)).flat()
    const ret = creator(tagName, attributes, children)
    return ret
  }

  return jsx
}

View on GitHub (pinned to 72a37c701e)

Solutions

  1. Register the tag: createHyperscript({ elements: { mytag: { type: 'my-type' } } })
  2. Use the built-in tags only (<element>, <text>, <editor>, <selection>, <anchor>, <focus>, <cursor>, <selection>)
  3. Check for typos in the tag name against the creators object

Example fix

// before
const jsx = createHyperscript(hyperscriptCreators)
// after
const jsx = createHyperscript({
  ...hyperscriptCreators,
  elements: { mytag: { type: 'my-type' } },
})
Defensive patterns

Strategy: validation

Validate before calling

const jsx = createHyperscript({
  ...hyperscriptCreators,
  elements: { mytag: { type: 'my-type' } },
})
// verify before use:
if (!('mytag' in (jsx.creators ?? {}))) throw new Error('tag not registered')

Type guard

const isRegisteredTag = (creators: Record<string, unknown>, tag: string): boolean =>
  Object.prototype.hasOwnProperty.call(creators, tag)

Try / catch

null

Prevention

When it happens

Trigger: Calling jsx('mytag', ...) or <mytag> in hyperscript JSX without registering it via createHyperscript({ creators: { mytag: ... } }) or elements: { mytag: {...} }.

Common situations: Using custom block types in tests without extending the hyperscript factory; typos in tag names; using slate-hyperscript's default tags while assuming custom schema types exist.

Related errors


AI-assisted analysis of ianstormtaylor/slate@72a37c701e (2026-08-27). Data as JSON: /api/errors/aa654dbd2c3635d1. Report an issue: GitHub.