nwjs/nw.js · error · TypeException
Expecting get(string, optional boolean) or get(ClipboardData
Error message
Expecting get(string, optional boolean) or get(ClipboardData[]) or get(ClipboardData).
What it means
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.
Source
Thrown at src/resources/api_nw_clipboard.js:48
clipboard = new NWClipboard();
return clipboard;
};
NWClipboard.prototype.get = function (type, raw) {
var toString = $Object.prototype.toString;
// get(ClipboardData[])
if (arguments.length === 1 && toString.apply(type) === '[object Array]') {
return nwClipboardBinding.getListSync(type);
}
// get(DOMString, boolean)
if (!type || toString.apply(type) === '[object String]') {
return nwClipboardBinding.getListSync([{type: type || 'text', raw: !!raw}])[0].data;
}
// get(ClipboardData)
if (arguments.length === 1) {
return nwClipboardBinding.getListSync([type])[0].data;
}
throw new TypeException('Expecting get(string, optional boolean) or get(ClipboardData[]) or get(ClipboardData).');
};
NWClipboard.prototype.set = function (content, type, raw) {
var toString = $Object.prototype.toString;
// set(ClipboardData[])
if (arguments.length === 1 && toString.apply(content) === '[object Array]') {
return nwClipboardBinding.setListSync(content);
}
// set(DOMString, DOMString, boolean)
if (toString.apply(content) === '[object String]') {
return nwClipboardBinding.setListSync([{type: type || 'text', raw: !!raw, data: content}]);
}
// set(ClipboardData)
if (arguments.length === 1) {
return nwClipboardBinding.setListSync([content]);
}
throw new TypeException('Expecting set(string, optional string, optional boolean) or set(ClipboardData[]) or set(ClipboardData).');
};
NWClipboard.prototype.clear = function () {View on GitHub (pinned to e15da848e9)
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 })`.
Example fix
// before
const text = nw.Clipboard.get();
// after
const text = nw.Clipboard.get('text'); Defensive patterns
Strategy: validation
Validate before calling
function safeGet(arg) {
if (arguments.length === 0) return nw.Clipboard.get('text');
return nw.Clipboard.get(arg);
} Type guard
function isClipboardDataArray(v) { return Array.isArray(v) && v.every(i => i && typeof i === 'object' && typeof i.type === 'string'); } Try / catch
try { return nw.Clipboard.get(type, raw); } catch (e) { if (/Expecting get/.test(e.message)) return nw.Clipboard.get('text'); throw e; } Prevention
- Always pass an explicit type string ('text', 'png', etc.).
- Wrap clipboard calls in a helper that normalizes arguments.
When it happens
Trigger: Calling `nw.Clipboard.get()` with no args, `nw.Clipboard.get(123)`, or `nw.Clipboard.get(true, false, true)` (3 args).
Common situations: Assuming get() with no arguments returns plain text (it does not — pass 'text' explicitly); passing a number where a type string is expected.
Related errors
- Expecting set(string, optional string, optional boolean) or
- Type of '{type}' is not supported
- Only support getting plain text from Clipboard
- 'active' must be a valid function.
- 'failed' must be a valid function.
AI-assisted analysis of nwjs/nw.js@e15da848e9 (2026-08-13).
Data as JSON: /api/errors/1347c0738eb65452.
Report an issue: GitHub.