{"record":{"id":"3d0b44e6bb61ea81","repo":"nwjs/nw.js","slug":"invalid-menu-type-option-type-3d0b44","errorCode":null,"errorMessage":"Invalid menu type: {option.type}","messagePattern":"Invalid menu type: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/resources/api_nw_menu.js","lineNumber":13,"sourceCode":"var forEach = require('utils').forEach;\nvar nwNative = requireNative('nw_natives');\nvar messagingNatives = requireNative('messaging_natives');\n\nfunction Menu (option) {\n  if (!(this instanceof Menu)) {\n    return new Menu(option);\n  }\n\n  if (typeof option != 'object' || !option)\n    option = { type: 'contextmenu' };\n  if (option.type != 'contextmenu' && option.type != 'menubar')\n    throw new TypeError('Invalid menu type: ' + option.type);\n\n  var id = nw.Obj.allocateId();\n  option.generatedId = id;\n\n  this.id = id;\n  this.type = option.type;\n  privates(this).items = [];\n  privates(this).option = option;\n\n  var items = privates(this).items;\n  nw.Obj.create(id, 'Menu', option);\n  messagingNatives.BindToGC(this, function() { items.forEach(function(element) { element._destroy(); }); nw.Obj.destroy(id); });\n};\n\nMenu.prototype.__defineGetter__('items', function() {\n  return privates(this).items;\n});\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/nwjs/nw.js/blob/e15da848e9e08e6e467532dae78995c6ad2f55ee/src/resources/api_nw_menu.js#L1-L31","documentation":"Thrown by the nw.Menu constructor when option.type is present but is neither 'contextmenu' nor 'menubar'. These are the only two menu kinds nw supports (a popup context menu or an application menu bar).","triggerScenarios":"Calling `new nw.Menu({ type: 'toolbar' })`, `new nw.Menu({ type: 'dropdown' })`, or `new nw.Menu({ type: 'Menubar' })` (case mismatch).","commonSituations":"Typo in the type string; using a type name from a different framework (Electron uses 'submenu'); case sensitivity.","solutions":["Use 'contextmenu' or 'menubar' exactly (lowercase).","Omit type entirely to default to 'contextmenu'."],"exampleFix":"// before\nnew nw.Menu({ type: 'Menubar' });\n// after\nnew nw.Menu({ type: 'menubar' });","handlingStrategy":"validation","validationCode":"const allowed = ['contextmenu', 'menubar'];\nif (option && option.type && allowed.indexOf(option.type) === -1) option.type = 'contextmenu';","typeGuard":"function isMenuType(v) { return v === 'contextmenu' || v === 'menubar'; }","tryCatchPattern":"try { new nw.Menu(opt); } catch (e) { if (/Invalid menu type/.test(e.message)) new nw.Menu(); else throw e; }","preventionTips":["Restrict type to the two allowed values in your config schema.","Lowercase the type string before passing."],"tags":["menu","constructor","enum","nwjs"],"backgroundTag":null,"analyzedSha":"e15da848e9e08e6e467532dae78995c6ad2f55ee","analyzedAt":"2026-08-13T04:15:35.452Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}