{"record":{"id":"1347c0738eb65452","repo":"nwjs/nw.js","slug":"expecting-get-string-optional-boolean-or-get-cli","errorCode":null,"errorMessage":"Expecting get(string, optional boolean) or get(ClipboardData[]) or get(ClipboardData).","messagePattern":"Expecting get\\(string, optional boolean\\) or get\\(ClipboardData\\[\\]\\) or get\\(ClipboardData\\)\\.","errorType":"validation","errorClass":"TypeException","httpStatus":null,"severity":"error","filePath":"src/resources/api_nw_clipboard.js","lineNumber":48,"sourceCode":"  clipboard = new NWClipboard();\n  return clipboard;\n};\n\nNWClipboard.prototype.get = function (type, raw) {\n  var toString = $Object.prototype.toString;\n  // get(ClipboardData[])\n  if (arguments.length === 1 && toString.apply(type) === '[object Array]') {\n    return nwClipboardBinding.getListSync(type);\n  }\n  // get(DOMString, boolean)\n  if (!type || toString.apply(type) === '[object String]') {\n    return nwClipboardBinding.getListSync([{type: type || 'text', raw: !!raw}])[0].data;\n  }\n  // get(ClipboardData)\n  if (arguments.length === 1) {\n    return nwClipboardBinding.getListSync([type])[0].data;\n  }\n  throw new TypeException('Expecting get(string, optional boolean) or get(ClipboardData[]) or get(ClipboardData).');\n};\nNWClipboard.prototype.set = function (content, type, raw) {\n  var toString = $Object.prototype.toString;\n  // set(ClipboardData[])\n  if (arguments.length === 1 && toString.apply(content) === '[object Array]') {\n    return nwClipboardBinding.setListSync(content);\n  }\n  // set(DOMString, DOMString, boolean)\n  if (toString.apply(content) === '[object String]') {\n    return nwClipboardBinding.setListSync([{type: type || 'text', raw: !!raw, data: content}]);\n  }\n  // set(ClipboardData)\n  if (arguments.length === 1) {\n    return nwClipboardBinding.setListSync([content]);\n  }\n  throw new TypeException('Expecting set(string, optional string, optional boolean) or set(ClipboardData[]) or set(ClipboardData).');\n};\nNWClipboard.prototype.clear = function () {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/nwjs/nw.js/blob/e15da848e9e08e6e467532dae78995c6ad2f55ee/src/resources/api_nw_clipboard.js#L30-L66","documentation":"Thrown by nw.Clipboard.get when arguments match none of the supported overloads: get(string[, boolean]), get(ClipboardData[]), or get(ClipboardData). The dispatcher checks argument count and type tags (Array, String, object) and falls through to a TypeException if none match.","triggerScenarios":"Calling `nw.Clipboard.get()` with no args, `nw.Clipboard.get(123)`, or `nw.Clipboard.get(true, false, true)` (3 args).","commonSituations":"Assuming get() with no arguments returns plain text (it does not — pass 'text' explicitly); passing a number where a type string is expected.","solutions":["For text: `nw.Clipboard.get('text')`.","For multiple types: `nw.Clipboard.get([{ type: 'text' }, { type: 'png' }])`.","For a single ClipboardData object: `nw.Clipboard.get({ type: 'text', raw: false })`."],"exampleFix":"// before\nconst text = nw.Clipboard.get();\n// after\nconst text = nw.Clipboard.get('text');","handlingStrategy":"validation","validationCode":"function safeGet(arg) {\n  if (arguments.length === 0) return nw.Clipboard.get('text');\n  return nw.Clipboard.get(arg);\n}","typeGuard":"function isClipboardDataArray(v) { return Array.isArray(v) && v.every(i => i && typeof i === 'object' && typeof i.type === 'string'); }","tryCatchPattern":"try { return nw.Clipboard.get(type, raw); } catch (e) { if (/Expecting get/.test(e.message)) return nw.Clipboard.get('text'); throw e; }","preventionTips":["Always pass an explicit type string ('text', 'png', etc.).","Wrap clipboard calls in a helper that normalizes arguments."],"tags":["clipboard","overload","type-check","nwjs"],"backgroundTag":null,"analyzedSha":"e15da848e9e08e6e467532dae78995c6ad2f55ee","analyzedAt":"2026-08-13T04:15:35.452Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}