ReactiveX/rxjs · error · Error

Unknown option: ${argument}

Error message

Unknown option: ${argument}

What it means

Thrown by parseArguments when the command line contains a token starting with '-' that does not match any known flag. The CLI rejects unknown options outright rather than silently ignoring them, so misspelled flags fail fast.

Source

Thrown at packages/migrate/src/cli.ts:158

        if (mode !== 'cold' && mode !== 'platform') throw new Error(`Unknown mode: ${mode}`);
        options.mode = mode;
        break;
      }
      case '--framework': {
        const framework = requiredValue(argv, ++index, argument);
        if (framework !== 'preserve' && framework !== 'mocha-chai-vitest') throw new Error(`Unknown framework: ${framework}`);
        options.framework = framework;
        break;
      }
      case '--write':
        options.write = true;
        break;
      case '--help':
      case '-h':
        options.help = true;
        break;
      default:
        if (argument.startsWith('-')) throw new Error(`Unknown option: ${argument}`);
        options.files.push(argument);
    }
  }
  return options;
}

function validateArguments(options: CliOptions): asserts options is RunnableCliOptions {
  const missing = [
    options.files.length === 0 ? 'at least one source file' : undefined,
    options.sourceRoot ? undefined : '--source-root',
    options.repository ? undefined : '--source-repo',
    options.sha ? undefined : '--source-sha',
  ].filter((value): value is string => value !== undefined);
  if (missing.length > 0) throw new Error(`Missing required argument${missing.length === 1 ? '' : 's'}: ${missing.join(', ')}`);
  if (options.write && !options.outputRoot) throw new Error('--out-dir is required with --write');
}

function requiredValue(argv: readonly string[], index: number, option: string): string {

View on GitHub (pinned to 54796b38a5)

Solutions

  1. Remove the unsupported flag
  2. Check spelling against the --help output
  3. Replace with the supported equivalent (e.g. --write instead of --dry-run semantics)

Example fix

# before
npx @rxjs/migrate --dry-run file.ts
# after
npx @rxjs/migrate file.ts   # plan is printed by default; add --write to apply
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN_FLAGS = new Set(['--source-root','--source-repo','--source-sha','--mode','--framework','--write','--out-dir','--help','-h']);
for (const a of argv) if (a.startsWith('-') && !KNOWN_FLAGS.has(a)) throw new Error(`Unsupported flag in wrapper: ${a}`);

Type guard

const isKnownFlag = (a: string) => a.startsWith('-') && KNOWN_FLAGS.has(a);

Try / catch

try { runCli(argv); } catch (e) { console.error((e as Error).message); /* prints the exact unknown option */ }

Prevention

When it happens

Trigger: Passing an unsupported flag such as --dry-run, --verbose, or -v, or a typo like --source-rrot. Any token beginning with '-' that is not in the switch statement hits the default case and throws.

Common situations: Assuming flags from other codemods (jest-codemods, ts-migrate), using short forms that do not exist, or leftover flags in a reused npm script.

Related errors


AI-assisted analysis of ReactiveX/rxjs@54796b38a5 (2026-08-28). Data as JSON: /api/errors/e38f64b619cacc97. Report an issue: GitHub.