emberjs/ember.js · error · Exception

Unknown type: ${object.type}

Error message

Unknown type: ${object.type}

What it means

At the top of traversal, the visitor dispatches on object.type; if no handler exists for that type it throws 'Unknown type'. Marked as sanity code — it means an object in the AST (or passed to visit) has a type no visitor method covers.

Source

Thrown at packages/@handlebars/parser/lib/visitor.js:62

    for (let i = 0, l = array.length; i < l; i++) {
      this.acceptKey(array, i);

      if (!array[i]) {
        array.splice(i, 1);
        i--;
        l--;
      }
    }
  },

  accept: function (object) {
    if (!object) {
      return;
    }

    /* istanbul ignore next: Sanity code */
    if (!this[object.type]) {
      throw new Exception('Unknown type: ' + object.type, object);
    }

    if (this.current) {
      this.parents.unshift(this.current);
    }
    this.current = object;

    let ret = this[object.type](object);

    this.current = this.parents.shift();

    if (!this.mutating || ret) {
      return ret;
    } else if (ret !== false) {
      return object;
    }
  },

View on GitHub (pinned to 26f97246a8)

Solutions

  1. Add a handler for the node type on the visitor (this['MyType'] = function(node) {...})
  2. Align package versions so parser and visitor share the same AST spec (ember-source / @glimmer sync)
  3. Log object.type at the failure point to identify the malformed node
  4. Validate or fix hand-constructed nodes' type fields

Example fix

// before
visitor.visit({ type: 'Mustache' })
// after
visitor.visit({ type: 'MustacheStatement' })
Defensive patterns

Strategy: validation

Validate before calling

function hasHandler(v) { return v != null && typeof v.type === 'string' && typeof visitor[v.type] === 'function'; }
if (!hasHandler(root)) throw new TypeError('No visitor handler for type: ' + root && root.type);

Type guard

function isVisitable(v) { return v != null && typeof v.type === 'string' && typeof Visitor.prototype[v.type] === 'function'; }

Try / catch

try { visitor.visit(ast); } catch (e) { if (/Unknown type/.test(e.message)) { console.error('Bad node type in AST:', e.message); } throw e; }

Prevention

When it happens

Trigger: Visiting an object whose .type is misspelled, undefined, or from a newer AST spec than the visitor supports; passing non-AST objects into visitor.visit.

Common situations: Version mismatch between parser and visitor/transform packages; hand-built AST fragments with bad type fields; custom node kinds without registered handlers.

Related errors


AI-assisted analysis of emberjs/ember.js@26f97246a8 (2026-09-01). Data as JSON: /api/errors/99fcbf9d22fe3a6a. Report an issue: GitHub.