{"record":{"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/1fa9837ec26533512fdcad8baebf249771bd340a/packages/utils/src/diff/getType.ts#L47-L67","documentation":"getType classifies a value for diff rendering by walking every typeof branch (undefined, object subtypes, symbol, etc.). The final throw is a defensive guard for values whose typeof returns something not in the handled set. In standard ECMAScript this branch is effectively unreachable because typeof covers all values, but it can be triggered by exotic host objects or Proxies that intercept the typeof operation via Symbol.toStringTag tricks.","triggerScenarios":"Passing a value to a diff/assertion path whose typeof result is none of the handled strings — e.g. a Proxy or host exotic object that returns a non-standard typeof, or a modified globalThis with deleted constructors causing constructor checks to throw before reaching the guard.","commonSituations":"Very rare; seen with custom Proxy objects in test data, browser-specific exotic objects, or VM sandbox leaks. Almost always indicates a bug in test data construction rather than a config issue.","solutions":["Inspect the actual value being asserted/diffed to find the exotic object causing the unhandled typeof.","Avoid passing Proxy or host exotic objects directly to expect matchers that trigger deep equality/diff.","Use a plain serializable copy (structuredClone or JSON round-trip) of the exotic value before asserting."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isDiffableValue(value: unknown): boolean {\n  const t = typeof value\n  return value === null\n    || ['undefined','boolean','number','string','bigint','symbol','function','object'].includes(t)\n}","tryCatchPattern":null,"preventionTips":["Avoid passing Proxy or exotic host objects to expect matchers that deep-compare.","Convert exotic objects to plain copies before assertion."],"tags":["diff","type-detection","edge-case","internal-guard"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}