{"record":{"id":"3fd2dd91f890a343","repo":"oven-sh/bun","slug":"bun-svelte-plugin-forceside-must-be-a-string-got","errorCode":null,"errorMessage":"bun-svelte-plugin: forceSide must be a string, got ${typeof opts.forceSide}","messagePattern":"bun-svelte-plugin: forceSide must be a string, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/bun-plugin-svelte/src/options.ts","lineNumber":40,"sourceCode":"   */\n  development?: boolean;\n\n  /**\n   * Options to forward to the Svelte compiler.\n   */\n  compilerOptions?: OverrideCompileOptions;\n}\n\n/**\n * @internal\n */\nexport function validateOptions(options: unknown): asserts options is SvelteOptions {\n  assert(options && typeof options === \"object\", new TypeError(\"bun-svelte-plugin: options must be an object\"));\n  const opts = options as Record<keyof SvelteOptions, unknown>;\n\n  if (opts.forceSide != null) {\n    if (typeof opts.forceSide !== \"string\") {\n      throw new TypeError(\"bun-svelte-plugin: forceSide must be a string, got \" + typeof opts.forceSide);\n    }\n    switch (opts.forceSide) {\n      case \"client\":\n      case \"server\":\n        break;\n      default:\n        throw new TypeError(`bun-svelte-plugin: forceSide must be either 'client' or 'server', got ${opts.forceSide}`);\n    }\n  }\n\n  if (opts.compilerOptions) {\n    if (typeof opts.compilerOptions !== \"object\") {\n      throw new TypeError(\"bun-svelte-plugin: compilerOptions must be an object\");\n    }\n  }\n}\n\n/**","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/packages/bun-plugin-svelte/src/options.ts#L22-L58","documentation":"validateOptions() for the Bun Svelte plugin checks every option before the plugin is constructed. When forceSide is provided (non-null) it must be a string; any other type (boolean, number, object) raises this TypeError at configuration time, before any build work starts.","triggerScenarios":"Calling Bun.svelte({ forceSide: true }), forceSide: 1, forceSide: ['client'], or any non-string value from untyped config (CLI flags parsed as booleans, JSON with wrong types).","commonSituations":"Users assuming forceSide is a boolean toggle; passing options parsed from CLI args or user JSON where 'true' became true; JS callers bypassing the SvelteOptions TypeScript types.","solutions":["Pass a string: 'client' or 'server'","Omit forceSide entirely to let the plugin infer the side from build flags","Type your config object as SvelteOptions so the mistake is caught at compile time"],"exampleFix":"// before\nBun.svelte({ forceSide: true });\n\n// after\nBun.svelte({ forceSide: 'server' });","handlingStrategy":"type-guard","validationCode":"const opts: unknown = { forceSide: 'server' };\nif ('forceSide' in (opts as object) && (opts as any).forceSide != null && typeof (opts as any).forceSide !== 'string') {\n  throw new TypeError('forceSide must be a string');\n}","typeGuard":"function isSvelteOptions(o: unknown): o is BunSveltePlugin.SvelteOptions {\n  if (!o || typeof o !== 'object') return false;\n  const { forceSide, compilerOptions } = o as Record<string, unknown>;\n  if (forceSide != null && typeof forceSide !== 'string') return false;\n  if (compilerOptions != null && typeof compilerOptions !== 'object') return false;\n  return true;\n}","tryCatchPattern":null,"preventionTips":["Type plugin options as SvelteOptions so TS rejects wrong types at compile time","Validate untyped config (CLI/env/JSON) before handing it to Bun.svelte()"],"tags":["svelte","plugin","typescript","validation"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}