{"id":"a31bb478a51c58a6","repo":"evanw/esbuild","slug":"quote-key-must-be-mustbe","errorCode":null,"errorMessage":"${quote(key)} must be ${mustBe}","messagePattern":"(.+?) must be (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/shared/common.ts","lineNumber":82,"sourceCode":"  typeof value === 'string' || typeof value === 'object' && value !== null && !Array.isArray(value) ? null : 'a string or an object'\n\nlet mustBeStringOrArrayOfStrings = (value: string | string[] | undefined): string | null =>\n  typeof value === 'string' || (Array.isArray(value) && value.every(x => typeof x === 'string')) ? null : 'a string or an array of strings'\n\nlet mustBeStringOrUint8Array = (value: string | Uint8Array | undefined): string | null =>\n  typeof value === 'string' || value instanceof Uint8Array ? null : 'a string or a Uint8Array'\n\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 {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/evanw/esbuild/blob/6ff1d8b0d8c134e867a397eef39702a223ebef9e/lib/shared/common.ts#L64-L100","documentation":"Error \"${quote(key)} must be ${mustBe}\" thrown in evanw/esbuild.","triggerScenarios":"Thrown at lib/shared/common.ts:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide the option in the required form stated in the error message","Check the esbuild documentation for the correct value shape for this key"],"exampleFix":"// e.g. \"outdir\" must be a string\nesbuild.buildSync({ outdir: 'dist' });","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"6ff1d8b0d8c134e867a397eef39702a223ebef9e","analyzedAt":"2026-08-03T19:42:38.433Z","schemaVersion":2}