{"record":{"id":"54669fb3572e8fd3","repo":"nwjs/nw.js","slug":"invalid-option-54669f","errorCode":null,"errorMessage":"Invalid option.","messagePattern":"Invalid option\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/resources/api_nw_shortcut.js","lineNumber":155,"sourceCode":"function registerLocal(shortcut) {\n  var localKey = normalizeLocal(shortcut._accelerator);\n  handlers[localKey] = shortcut;\n}\n\nfunction unregisterLocal(shortcut) {\n  var localKey = normalizeLocal(shortcut._accelerator);\n  delete handlers[localKey];\n}\n\nfunction Shortcut(option) {\n  if (!(this instanceof Shortcut)) {\n    return new Shortcut(option);\n  }\n\n  EventEmitter.apply(this, arguments);\n\n  if (typeof option != 'object')\n    throw new TypeError(OPTION_INVALID);\n\n  if (!option.key)\n    throw new TypeError(OPTION_KEY_REQUIRED);\n\n  if (option.hasOwnProperty('active')) {\n    if (typeof option.active != 'function')\n      throw new TypeError(OPTION_ACTIVE_INVALID);\n  }\n\n  if (option.hasOwnProperty('failed')) {\n    if (typeof option.failed != 'function')\n      throw new TypeError(OPTION_FAILED_INVALID);\n  }\n\n  var self = this;\n\n  this.on('active', function() {\n    if (!self.active) return;","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/nwjs/nw.js/blob/e15da848e9e08e6e467532dae78995c6ad2f55ee/src/resources/api_nw_shortcut.js#L137-L173","documentation":"Thrown by the Shortcut constructor when the option argument is not an object (typeof option != 'object'). This catches primitive arguments, undefined, and null — the constructor requires an option object that at least carries a 'key' property. Note that typeof null === 'object' in JS, so null is NOT caught here and will instead fail later at the !option.key check.","triggerScenarios":"new nw.Shortcut('ctrl+a') (passing a string instead of an options object); new nw.Shortcut() (no argument, option is undefined); new nw.Shortcut(42) (number).","commonSituations":"Migrating from an API that accepted a bare key string; forgetting the options wrapper; passing a variable that was never assigned.","solutions":["Pass an options object: new nw.Shortcut({ key: 'ctrl+a', active: fn }).","If you have a bare key string, wrap it: new nw.Shortcut({ key: myKeyString })."],"exampleFix":"// before\nnew nw.Shortcut('ctrl+a');\n// after\nnew nw.Shortcut({ key: 'ctrl+a' });","handlingStrategy":"type-guard","validationCode":"if (typeof option !== 'object' || option === null) {\n  throw new TypeError('Shortcut option must be a non-null object');\n}","typeGuard":"function isShortcutOption(o) { return typeof o === 'object' && o !== null && !Array.isArray(o); }","tryCatchPattern":null,"preventionTips":["Always pass an object literal to new nw.Shortcut().","If accepting external config, type-check before construction.","Remember null passes typeof 'object' — guard it explicitly."],"tags":["nwjs","shortcut","validation","constructor"],"backgroundTag":null,"analyzedSha":"e15da848e9e08e6e467532dae78995c6ad2f55ee","analyzedAt":"2026-08-13T04:15:35.452Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}