{"record":{"id":"e766fe848d401a79","repo":"ReactiveX/rxjs","slug":"rxjs-next-expand-options-must-be-an-object","errorCode":null,"errorMessage":"RxJS Next expand options must be an object.","messagePattern":"RxJS Next expand options must be an object\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/rxjs/src/expand.ts","lineNumber":25,"sourceCode":"  concurrent?: number;\n}\n\ndeclare global {\n  interface Observable<T> {\n    [expand]<R>(project: (value: T, index: number) => ObservableValue<R>, options?: ExpandOptions): Observable<T | R>;\n  }\n}\n\nObservable.prototype[expand] = function <T, R>(\n  this: Observable<T>,\n  project: (value: T, index: number) => ObservableValue<R>,\n  options?: ExpandOptions\n): Observable<T | R> {\n  if (arguments.length > 2) {\n    throw new TypeError('RxJS Next expand does not support a scheduler argument.');\n  }\n  if (options !== undefined && (typeof options !== 'object' || options === null)) {\n    throw new TypeError('RxJS Next expand options must be an object.');\n  }\n\n  const configuredConcurrency = options?.concurrent ?? Infinity;\n  const concurrency = configuredConcurrency >= 1 ? configuredConcurrency : Infinity;\n\n  return this[create]((subscriber) => {\n    const queue: Array<T | R> = [];\n    let active = 0;\n    let index = 0;\n    let sourceComplete = false;\n    let draining = false;\n\n    const checkComplete = (): void => {\n      if (sourceComplete && active === 0 && queue.length === 0 && subscriber.active) {\n        subscriber.complete();\n      }\n    };\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/ReactiveX/rxjs/blob/54796b38a57e6309f9861e174737479bb3f63f61/packages/rxjs/src/expand.ts#L7-L43","documentation":"The second parameter of expand in RxJS Next must be an options object (with an optional concurrent number) or undefined. Passing a primitive (number, string, boolean) or null — e.g. the legacy concurrency number — throws this TypeError.","triggerScenarios":"observable[expand](project, 5) — RxJS 7 allowed a numeric concurrency as the second argument; also expand(fn, null) or expand(fn, 'x').","commonSituations":"Migrated RxJS 7 code that passed concurrency positionally: expand(project, 1) for breadth-first traversal limiting.","solutions":["Wrap the concurrency in the options object: expand(project, { concurrent: 5 })","Pass undefined or omit the second argument when no options are needed"],"exampleFix":"// before\nsource[expand](project, 1);\n// after\nsource[expand](project, { concurrent: 1 });","handlingStrategy":"validation","validationCode":"if (options !== undefined && (typeof options !== 'object' || options === null)) {\n  options = { concurrent: options as number }; // coerce legacy numeric concurrency\n}\nobs[expand](project, options);","typeGuard":"const isExpandOptions = (v: unknown): v is { concurrent?: number } =>\n  v === undefined || (typeof v === 'object' && v !== null);","tryCatchPattern":null,"preventionTips":["Wrap numeric concurrency in { concurrent: n }","Type the second parameter as ExpandOptions | undefined"],"tags":["expand","options-object","rxjs-next","migration"],"backgroundTag":"invalid-argument-shape","analyzedSha":"54796b38a57e6309f9861e174737479bb3f63f61","analyzedAt":"2026-08-28T10:21:27.410Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}