{"record":{"id":"10b8917aee2c8e43","repo":"dotnet/aspnetcore","slug":"the-options-parameter-is-required","errorCode":null,"errorMessage":"The options parameter is required.","messagePattern":"The options parameter is required\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Rendering/Events/EventTypes.ts","lineNumber":17,"sourceCode":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\nexport interface EventTypeOptions {\n  browserEventName?: string;\n  createEventArgs?: (event: Event) => unknown;\n}\n\nconst eventTypeRegistry: Map<string, EventTypeOptions> = new Map();\nconst browserEventNamesToAliases: Map<string, string[]> = new Map();\nconst createBlankEventArgsOptions: EventTypeOptions = { createEventArgs: () => ({}) };\n\nexport const eventNameAliasRegisteredCallbacks: ((aliasEventName: string, browserEventName) => void)[] = [];\n\nexport function registerCustomEventType(eventName: string, options: EventTypeOptions): void {\n  if (!options) {\n    throw new Error('The options parameter is required.');\n  }\n\n  // There can't be more than one registration for the same event name because then we wouldn't\n  // know which eventargs data to supply.\n  if (eventTypeRegistry.has(eventName)) {\n    throw new Error(`The event '${eventName}' is already registered.`);\n  }\n\n  // When aliasing a browser event, the custom event name must be different from the browser event name\n  // to avoid double-triggering (once for the browser event, once for the custom event wrapper)\n  if (options.browserEventName && eventName === options.browserEventName) {\n    throw new Error(`The custom event '${eventName}' cannot have the same name as its browserEventName '${options.browserEventName}'. Choose a different name for the custom event.`);\n  }\n\n  // If applicable, register this as an alias of the given browserEventName\n  if (options.browserEventName) {\n    const aliasGroup = browserEventNamesToAliases.get(options.browserEventName);\n    if (aliasGroup) {","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Rendering/Events/EventTypes.ts#L1-L35","documentation":"Thrown by registerCustomEventType when the options argument is falsy. Custom event registration requires an EventTypeOptions object (at minimum to hold createEventArgs / browserEventName), so passing undefined/null/0 is rejected.","triggerScenarios":"Calling Blazor.registerCustomEventType('myevent') with no second argument, or passing an explicitly undefined options.","commonSituations":"Forgetting the options argument; conditionally building options and passing undefined when a branch is skipped; refactor that drops the options object.","solutions":["Always pass an EventTypeOptions object, even if only { createEventArgs: e => ({}) }.","If you have nothing to customize, pass an empty object {} rather than undefined.","Add a TypeScript check that options is non-null before calling registerCustomEventType."],"exampleFix":"// before\nBlazor.registerCustomEventType('myevent'); // throws\n\n// after\nBlazor.registerCustomEventType('myevent', {\n  createEventArgs: e => ({ detail: e.detail })\n});","handlingStrategy":"validation","validationCode":"// Validate options before registering.\nfunction register(name: string, options?: EventTypeOptions) {\n  if (!options) throw new Error('options required');\n  Blazor.registerCustomEventType(name, options);\n}","typeGuard":"function isValidOptions(o: unknown): o is EventTypeOptions {\n  return !!o && typeof o === 'object';\n}","tryCatchPattern":null,"preventionTips":["Always pass an EventTypeOptions object, even if just { createEventArgs: e => ({}) }.","Type the call so undefined is rejected at compile time.","Default-coerce options ?? {} before calling."],"tags":["blazor","events","custom-event","validation"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}