{"id":"3b2bc49610220bfc","repo":"vitest-dev/vitest","slug":"value-of-unknown-type-value","errorCode":null,"errorMessage":"value of unknown type: ${value}","messagePattern":"value of unknown type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/utils/src/diff/getType.ts","lineNumber":65,"sourceCode":"        return 'regexp'\n      }\n      else if (value.constructor === Map) {\n        return 'map'\n      }\n      else if (value.constructor === Set) {\n        return 'set'\n      }\n      else if (value.constructor === Date) {\n        return 'date'\n      }\n    }\n    return 'object'\n  }\n  else if (typeof value === 'symbol') {\n    return 'symbol'\n  }\n\n  throw new Error(`value of unknown type: ${value}`)\n}\n","sourceCodeStart":47,"sourceCodeEnd":67,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/utils/src/diff/getType.ts#L47-L67","documentation":"Thrown by getType() in packages/utils/src/diff/getType.ts as a defensive guard at the end of the type-discrimination ladder. The function handles undefined, null, array, boolean, function, number, string, bigint, object (with regexp/map/set/date subtypes), and symbol. Falling through every branch means typeof returned a value TypeScript's union doesn't model — practically only reachable via a host quirk, a Proxy returning an exotic typeof, or a corrupted runtime.","triggerScenarios":"Passing a value from a Proxy whose typeof hook returns an exotic string; crossing realms where typeof behaves oddly; very old or non-conformant engines; values patched by tooling that changes typeof semantics.","commonSituations":"Effectively unreachable in standard V8/Node — usually indicates a tampered environment, a sandbox escape, or a bug in a serializer/differ invoked with a value whose prototype chain was mutated.","solutions":["Inspect the actual value passed to the differ and its typeof result in a debugger.","Remove any Proxy or Symbol.toPrimitive/toStringTag overrides that may distort typeof.","Update to a supported Node version (^20 || ^22 || >=24).","File a Vitest issue with a minimal reproduction if the value is a plain object/function."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function safeGetType(value: unknown): string {\n  try { return getType(value) } catch { return 'unknown' }\n}","typeGuard":"function isKnownType(value: unknown): boolean {\n  try { getType(value); return true } catch { return false }\n}","tryCatchPattern":"try {\n  // diff/serialization path that calls getType\n} catch (err) {\n  if (err.message.startsWith('value of unknown type')) {\n    // log the value's typeof and prototype for diagnosis, fall back to String(value)\n  } else throw err\n}","preventionTips":["Treat this error as a canary for a tampered runtime; inspect any Proxy or Symbol.toPrimitive on the value.","Keep Node on a supported version (^20 || ^22 || >=24).","Avoid patching built-in typeof behavior via tooling."],"tags":["utils","type-detection","defensive","unreachable"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}