{"record":{"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/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/lib/shared/common.ts#L71-L107","documentation":"After all recognized options are read, checkForInvalidFlags() (lib/shared/common.ts:86) iterates the options object and rejects any property name it does not recognize. This deliberately turns silent typos and version-mismatched option names into a hard error so misconfiguration is never quietly ignored. The `where` string tells you which call's options object has the bad key.","triggerScenarios":"Passing a misspelled option (e.g. `enteryPoints`, `bundel`, `outpuFiles`), an option from a different esbuild version, or a stray property to build()/context()/transform()/initialize()/stdin/watch()/serve()/cors/entry-point objects.","commonSituations":"Typos; using a newer option on an older esbuild install (or vice versa); leftover keys copied from a different bundler's config (webpack/rollup); IDE autocomplete inserting the wrong name.","solutions":["Compare the offending key (quoted in the message) against esbuild's current option list and fix the spelling.","If the option is real but from a newer esbuild, upgrade the esbuild package; if from an older one, remove/replace it.","Strip unknown keys when forwarding arbitrary user config objects into esbuild."],"exampleFix":"// before\nawait build({ enteryPoints: ['app.ts'], bundle: true })\n\n// after\nawait build({ entryPoints: ['app.ts'], bundle: true })","handlingStrategy":"validation","validationCode":"import type { BuildOptions } from 'esbuild'\nconst KNOWN_BUILD_KEYS = new Set([\n  'entryPoints','bundle','outfile','outdir','format','target','platform','define',\n  'loader','plugins','sourcemap','minify','external','alias',\n  /* ...full list from esbuild docs */\n])\nfunction rejectUnknownKeys(opts: Record<string, unknown>, scope: string) {\n  for (const k of Object.keys(opts)) {\n    if (!KNOWN_BUILD_KEYS.has(k)) throw new Error(`Unknown ${scope} option: ${k}`)\n  }\n}\nrejectUnknownKeys(opts, 'build')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let TypeScript check your options object against esbuild's types (excess property checks catch typos at the call site).","Keep the esbuild package version in sync with the docs you read.","Avoid forwarding arbitrary user/env objects directly as esbuild options; allowlist keys first."],"tags":["config","validation","typo","options","version"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}