{"record":{"id":"763f298fc7ffa029","repo":"nwjs/nw.js","slug":"invalid-menuitem-type-option-type-763f29","errorCode":null,"errorMessage":"Invalid MenuItem type: {option.type}","messagePattern":"Invalid MenuItem type: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/resources/api_nw_menuitem.js","lineNumber":32,"sourceCode":"  try{obj.emit('click')}catch(e){console.error(e)}\n});\n\nfunction MenuItem(option) {\n  if (!(this instanceof MenuItem)) {\n    return new MenuItem(option);\n  }\n  EventEmitter.apply(this);\n\n  if (typeof option != 'object')\n    throw new TypeError('Invalid option.');\n\n  if (!option.hasOwnProperty('type'))\n    option.type = 'normal';\n\n  if (option.type != 'normal' &&\n      option.type != 'checkbox' &&\n      option.type != 'separator')\n    throw new TypeError('Invalid MenuItem type: ' + option.type);\n\n  if (option.type == 'normal' || option.type == 'checkbox') {\n    if (option.type == 'checkbox')\n      option.checked = Boolean(option.checked);\n\n    if (!option.hasOwnProperty('label'))\n      throw new TypeError('A normal MenuItem must have a label');\n    else\n      option.label = String(option.label);\n\n    if (option.hasOwnProperty('icon')) {\n      option.shadowIcon = String(option.icon);\n      option.icon = nwNative.getAbsolutePath(option.icon);\n    }\n\n    if (option.hasOwnProperty('iconIsTemplate'))\n      option.iconIsTemplate = Boolean(option.iconIsTemplate);\n    else","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/nwjs/nw.js/blob/e15da848e9e08e6e467532dae78995c6ad2f55ee/src/resources/api_nw_menuitem.js#L14-L50","documentation":"Thrown by the nw.MenuItem constructor when option.type is set to a value other than 'normal', 'checkbox', or 'separator'. If type is omitted it defaults to 'normal'; an explicit invalid value is rejected.","triggerScenarios":"Calling `new nw.MenuItem({ type: 'radio' })`, `new nw.MenuItem({ type: 'button' })`, or `new nw.MenuItem({ type: 'Normal' })` (case mismatch).","commonSituations":"Porting code from Electron (which supports 'radio'); typo; case sensitivity.","solutions":["Use one of 'normal', 'checkbox', 'separator' (lowercase).","Omit type to default to 'normal'.","For radio-like behavior, use 'checkbox' and manage mutually-exclusive checked state yourself."],"exampleFix":"// before\nnew nw.MenuItem({ type: 'radio', label: 'Opt' });\n// after\nnew nw.MenuItem({ type: 'checkbox', label: 'Opt' });","handlingStrategy":"validation","validationCode":"const allowed = ['normal', 'checkbox', 'separator'];\nif (option.type && allowed.indexOf(option.type) === -1) option.type = 'normal';","typeGuard":"function isMenuItemType(v) { return ['normal', 'checkbox', 'separator'].indexOf(v) !== -1; }","tryCatchPattern":"try { new nw.MenuItem(opt); } catch (e) { if (/Invalid MenuItem type/.test(e.message)) { opt.type = 'normal'; new nw.MenuItem(opt); } else throw e; }","preventionTips":["Lowercase and validate the type before construction.","Note that 'radio' is not supported — use 'checkbox'."],"tags":["menuitem","constructor","enum","nwjs"],"backgroundTag":null,"analyzedSha":"e15da848e9e08e6e467532dae78995c6ad2f55ee","analyzedAt":"2026-08-13T04:15:35.452Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}