{"record":{"id":"ac0250e737f7d79e","repo":"oven-sh/bun","slug":"could-not-parse-directive-contents-slice-0-con","errorCode":null,"errorMessage":"Could not parse directive:\n${contents.slice(0, contents.indexOf(\"\\n\"))}","messagePattern":"Could not parse directive:\n(.+?)","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"src/codegen/bundle-functions.ts","lineNumber":181,"sourceCode":"    } else if (match[1] === \"type\" || match[1] === \"export type\") {\n      const i = contents.search(consumeEndOfType);\n      contents = contents.slice(i + 1);\n    } else if (match[1] === \"interface\") {\n      contents = sliceSourceCode(contents, false).rest;\n    } else if (match[1] === \"const enum\") {\n      const { result, rest } = sliceSourceCode(contents, false);\n      const i = result.indexOf(\"{\\n\");\n      // Support const enums in module scope.\n      topLevelEnums.push({\n        name: result.slice(\"const enum \".length, i).trim(),\n        code: \"\\n\" + result,\n      });\n\n      contents = rest;\n    } else if (match[1] === \"$\") {\n      const directive = contents.match(/^\\$([a-zA-Z0-9]+)(?:\\s*=\\s*([^\\r\\n]+?))?\\s*;?\\r?\\n/);\n      if (!directive) {\n        throw new SyntaxError(\"Could not parse directive:\\n\" + contents.slice(0, contents.indexOf(\"\\n\")));\n      }\n      const name = directive[1];\n      let value;\n      try {\n        value = directive[2] ? JSON.parse(directive[2]) : true;\n      } catch (error) {\n        throw new SyntaxError(\"Could not parse directive value \" + directive[2] + \" (must be JSON parsable)\");\n      }\n      if (name === \"constructor\") {\n        directives.ConstructAbility = \"CanConstruct\";\n      } else {\n        directives[name] = value;\n      }\n      contents = contents.slice(directive[0].length);\n    } else if (match[1] === \"export function\" || match[1] === \"export async function\") {\n      // consume async token and function name\n      const nameMatch = contents.match(/^export\\s+(async\\s+)?function\\s([_a-zA-Z0-9]+)\\s*/);\n      if (!nameMatch)","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bundle-functions.ts#L163-L199","documentation":"Error \"Could not parse directive:\n${contents.slice(0, contents.indexOf(\"\\n\"))}\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/codegen/bundle-functions.ts:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}