angular/angular-cli · error

Unrecognized arguments.

Error message

Unrecognized arguments.

What it means

register() only recognizes two call shapes: register(name, handler, options?) and register(handler, options?). If the first argument is neither a string nor a valid JobHandler, the registry cannot interpret the call and throws 'Unrecognized arguments.' as a catch-all TypeError.

Source

Thrown at packages/angular_devkit/architect/src/jobs/simple-registry.ts:93

        // This is an error.
        throw new TypeError('Expected a JobHandler as second argument.');
      }

      this._register(nameOrHandler, handlerOrOptions, options);
    } else if (isJobHandler(nameOrHandler)) {
      if (typeof handlerOrOptions !== 'object') {
        // This is an error.
        throw new TypeError('Expected an object options as second argument.');
      }

      const name = options.name || nameOrHandler.jobDescription.name || handlerOrOptions.name;
      if (name === undefined) {
        throw new TypeError('Expected name to be a string.');
      }

      this._register(name, nameOrHandler, options);
    } else {
      throw new TypeError('Unrecognized arguments.');
    }
  }

  protected _register<
    ArgumentT extends JsonValue,
    InputT extends JsonValue,
    OutputT extends JsonValue,
  >(
    name: JobName,
    handler: JobHandler<ArgumentT, InputT, OutputT>,
    options: RegisterJobOptions,
  ): void {
    if (this._jobNames.has(name)) {
      // We shouldn't allow conflicts.
      throw new JobNameAlreadyRegisteredException(name);
    }

    // Merge all fields with the ones in the handler (to make sure we respect the handler).

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Inspect the first argument; ensure it is either a non-empty string name or an awaited JobHandler.
  2. Await async handler creation before registering: registry.register(await createJobHandlerAsync(...)).
  3. Fix undefined first arguments caused by bad imports/initialization order (check the variable is assigned before the call).

Example fix

// before
registry.register(createJobHandlerAsync(config), { name: 'my-job' });
// after
const handler = await createJobHandlerAsync(config);
registry.register(handler, { name: 'my-job' });
Defensive patterns

Strategy: validation

Validate before calling

const first = nameOrHandlerOrPromise;
if (typeof first !== 'string' && !isJobHandler(first)) {
  throw new Error(`first argument to register() must be a string name or JobHandler, got ${first === undefined ? 'undefined' : typeof first} (is it an un-awaited Promise?)`);
}

Type guard

function isRegisterableFirstArg(v) {
  return typeof v === 'string' || isJobHandler(v);
}

Try / catch

try {
  registry.register(nameOrHandler, ...rest);
} catch (e) {
  if (e instanceof TypeError && /Unrecognized arguments/.test(e.message)) {
    throw new Error(`register() got invalid first argument (${typeof nameOrHandler}); check imports and await async factories`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing undefined/null/a Promise/a non-handler object as the first argument: register(undefined, handler), register(await createJobHandler(...)) without awaiting, register(null, ...).

Common situations: Forgetting to await an async handler factory so a Promise is passed; a variable that is undefined due to an import or initialization bug; passing an options object first by mistake.

Understand the failure class

Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/7a0039a20c073445. Report an issue: GitHub.