{"id":"421ecda677d91089","repo":"evanw/esbuild","slug":"invalid-option-where-quote-key","errorCode":null,"errorMessage":"Invalid option ${where}: ${quote(key)}","messagePattern":"Invalid option (.+?): (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/shared/common.ts","lineNumber":89,"sourceCode":"\nlet mustBeStringOrURL = (value: string | URL | undefined): string | null =>\n  typeof value === 'string' || value instanceof URL ? null : 'a string or a URL'\n\ntype OptionKeys = { [key: string]: boolean }\n\nfunction getFlag<T, K extends (keyof T & string)>(object: T, keys: OptionKeys, key: K, mustBeFn: (value: T[K]) => string | null): T[K] | undefined {\n  let value = object[key]\n  keys[key + ''] = true\n  if (value === undefined) return undefined\n  let mustBe = mustBeFn(value)\n  if (mustBe !== null) throw new Error(`${quote(key)} must be ${mustBe}`)\n  return value\n}\n\nfunction checkForInvalidFlags(object: Object, keys: OptionKeys, where: string): void {\n  for (let key in object) {\n    if (!(key in keys)) {\n      throw new Error(`Invalid option ${where}: ${quote(key)}`)\n    }\n  }\n}\n\nexport function validateInitializeOptions(options: types.InitializeOptions): types.InitializeOptions {\n  let keys: OptionKeys = Object.create(null)\n  let wasmURL = getFlag(options, keys, 'wasmURL', mustBeStringOrURL)\n  let wasmModule = getFlag(options, keys, 'wasmModule', mustBeWebAssemblyModule)\n  let worker = getFlag(options, keys, 'worker', mustBeBoolean)\n  checkForInvalidFlags(options, keys, 'in initialize() call')\n  return {\n    wasmURL,\n    wasmModule,\n    worker,\n  }\n}\n\ntype MangleCache = Record<string, string | false>","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/evanw/esbuild/blob/6ff1d8b0d8c134e867a397eef39702a223ebef9e/lib/shared/common.ts#L71-L107","documentation":"Error \"Invalid option ${where}: ${quote(key)}\" thrown in evanw/esbuild.","triggerScenarios":"Thrown at lib/shared/common.ts:89 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the invalid option or fix its name; it is not recognized in this context","Check for typos in option names and verify the option belongs to the API call being used"],"exampleFix":"// \"globalName\" is only valid for build, not transform\nesbuild.buildSync({ globalName: 'myLib', format: 'iife' });","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"6ff1d8b0d8c134e867a397eef39702a223ebef9e","analyzedAt":"2026-08-03T19:42:38.433Z","schemaVersion":2}