{"record":{"id":"3864de09153bf9a9","repo":"nwjs/nw.js","slug":"type-of-type-is-not-supported","errorCode":null,"errorMessage":"Type of '{type}' is not supported","messagePattern":"Type of '(.+?)' is not supported","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/api/clipboard/clipboard.js","lineNumber":33,"sourceCode":"// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n//  OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n//  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar clipboardInstance = null;\n\nfunction Clipboard() {\n  nw.allocateObject(this, {});\n}\nrequire('util').inherits(Clipboard, exports.Base);\n\nClipboard.prototype.set = function(data, type) {\n  if (typeof type == 'undefined')\n    type = 'text';\n\n  if (type != 'text')\n    throw new TypeError(\"Type of '\" + type + \"' is not supported\");\n\n  nw.callObjectMethod(this, 'Set', [ data, type ]);\n}\n\nClipboard.prototype.get = function(type) {\n  if (typeof type == 'undefined')\n    type = 'text';\n\n  if (type != 'text')\n    throw new TypeError('Only support getting plain text from Clipboard');\n\n  var result = nw.callObjectMethodSync(this, 'Get', [ type ]);\n  if (type == 'text')\n    return String(result);\n}\n\nClipboard.prototype.clear = function() {\n  nw.callObjectMethod(this, 'Clear', [ ]);","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/nwjs/nw.js/blob/e15da848e9e08e6e467532dae78995c6ad2f55ee/src/api/clipboard/clipboard.js#L15-L51","documentation":"Clipboard.prototype.set only supports the 'text' type. After defaulting type to 'text' when undefined, any other value (e.g., 'png', 'html', 'file') throws a TypeError before the native Set call. This is a deliberate limitation of the nw.js clipboard binding, not a generic clipboard API.","triggerScenarios":"Calling nw.Clipboard.get().set(data, 'html'), .set(data, 'png'), or .set(data, 'rtf'). Passing a typo like .set(data, 'Text') (capital T) also fails because the check is case-sensitive against the literal 'text'.","commonSituations":"Developers assume nw.js mirrors Electron/Chromium's clipboard with types like 'image/png' or 'html'. Migration from Electron where clipboard.writeText/writeImage were separate calls. Case-sensitivity mistakes ('Text' vs 'text').","solutions":["Call set(data) or set(data, 'text') — plain text is the only supported type.","If you need rich content (HTML/image), write the data to a temp file and put the path/text on the clipboard instead.","Double-check there is no capitalization typo in the type argument."],"exampleFix":"// before\nnw.Clipboard.get().set('<b>hi</b>', 'html'); // throws\n\n// after\nnw.Clipboard.get().set('<b>hi</b>', 'text'); // stored as literal text","handlingStrategy":"validation","validationCode":"function setText(data, type) {\n  type = (typeof type === 'undefined') ? 'text' : type;\n  if (type !== 'text') throw new Error('Unsupported clipboard type: ' + type);\n  nw.Clipboard.get().set(data, 'text');\n}","typeGuard":"function isTextType(t) { return t === undefined || t === 'text'; }","tryCatchPattern":"try { nw.Clipboard.get().set(data, type); }\ncatch (e) {\n  if (e instanceof TypeError && /not supported/.test(e.message)) {\n    nw.Clipboard.get().set(String(data), 'text'); // fall back to text\n  } else { throw e; }\n}","preventionTips":["Always call set(data) with no type, or set(data, 'text').","Never assume HTML/image types are supported; they are not.","Watch for capitalization: only lowercase 'text' passes."],"tags":["nwjs","clipboard","type-validation","unsupported-feature"],"backgroundTag":null,"analyzedSha":"e15da848e9e08e6e467532dae78995c6ad2f55ee","analyzedAt":"2026-08-13T04:15:35.452Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}