emberjs/ember.js · error · Error

`gt` expects exactly two arguments, but received ${arguments

Error message

`gt` expects exactly two arguments, but received ${arguments.length}.

What it means

The `gt` helper performs a greater-than comparison (left > right) in templates. A debug-only arity guard throws when the helper receives an argument count other than exactly two, which arises from direct JS invocation or a malformed wrapper rather than normal template use of `{{gt a b}}`.

Source

Thrown at packages/@glimmer/runtime/lib/helpers/gt.ts:10

import { DEBUG } from '@glimmer/env';

/**
 * Performs a greater than comparison.
 *
 * left > right
 */
export function gt<T>(left: T, right: T) {
  if (DEBUG && arguments.length !== 2) {
    throw new Error(`\`gt\` expects exactly two arguments, but received ${arguments.length}.`);
  }

  return (left as number) > (right as number);
}

View on GitHub (pinned to 26f97246a8)

Solutions

  1. Use `{{gt a b}}` in templates with exactly two arguments
  2. When calling from JS, pass exactly two arguments: `gt(a, b)`
  3. Fix wrappers to assert `positional.length === 2` before delegating

Example fix

// before
gt(count);
// after
gt(count, 10);
Defensive patterns

Strategy: validation

Validate before calling

function safeGt(...args) { if (args.length !== 2) throw new TypeError('gt requires exactly two arguments'); return gt(args[0], args[1]); }

Type guard

function hasTwoArgs<T extends unknown[]>(args: T): args is T & { length: 2 } { return args.length === 2; }

Try / catch

try { result = gt(a, b); } catch (e) { console.error('gt arity error:', e.message); result = false; }

Prevention

When it happens

Trigger: Calling `gt()` directly from JS with 1 or 3+ arguments; a custom helper forwarding positional args incorrectly; programmatic invocation missing the two required positional arguments.

Common situations: Test code calling the internal helper directly; refactoring a template comparison into JS; curry/wrapper utilities dropping or duplicating arguments.

Related errors


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