{"id":"f2f34020398a05ce","repo":"vitest-dev/vitest","slug":"name-value-must-be-types-join-or-recei","errorCode":null,"errorMessage":"${name} value must be ${types.join(' or ')}, received \"${receivedType}\"","messagePattern":"(.+?) value must be (.+?), received \"(.+?)\"","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/helpers.ts","lineNumber":47,"sourceCode":"  const stackTrace = err.stack || ''\n  Error.prepareStackTrace = prepareStackTrace\n  Error.stackTraceLimit = limit\n  return stackTrace\n}\n\nexport function notNullish<T>(v: T | null | undefined): v is NonNullable<T> {\n  return v != null\n}\n\nexport function assertTypes(\n  value: unknown,\n  name: string,\n  types: string[],\n): void {\n  const receivedType = typeof value\n  const pass = types.includes(receivedType)\n  if (!pass) {\n    throw new TypeError(\n      `${name} value must be ${types.join(' or ')}, received \"${receivedType}\"`,\n    )\n  }\n}\n\nexport function isPrimitive(value: unknown): boolean {\n  return (\n    value === null || (typeof value !== 'function' && typeof value !== 'object')\n  )\n}\n\nexport function slash(path: string): string {\n  return path.replace(/\\\\/g, '/')\n}\n\nconst postfixRE = /[?#].*$/\nexport function cleanUrl(url: string): string {\n  return url.replace(postfixRE, '')","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/utils/src/helpers.ts#L29-L65","documentation":"Thrown by assertTypes() in packages/utils/src/helpers.ts when the typeof a value is not in the allowed list passed by the caller. assertTypes is Vitest's internal runtime guard used across the codebase to validate config values, plugin inputs, and API arguments (e.g. functions, strings, booleans). The message reports the human-readable parameter name, the accepted typeof list, and the received typeof.","triggerScenarios":"Passing a number where Vitest expects a string or function in a public API (e.g. a reporter name, a setup file, a coverage option); passing undefined where an object is required; type-erased JS callers bypassing TypeScript and feeding wrong-shaped values.","commonSituations":"Plain-JS projects using Vitest without type checking; config typos; plugin/migration introducing a new required type; calling internal Vitest APIs from userland with the wrong runtime type.","solutions":["Read the error message: it states the expected typeof set and the received typeof — coerce or replace the value accordingly.","If the call is in your vitest.config, check the documented type of the option and align the value.","Add a runtime typeof check before calling the API to fail with a clearer message.","For TS users, run pnpm typecheck to catch the mismatch at compile time."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertRuntimeType(value: unknown, name: string, types: string[]): void {\n  if (!types.includes(typeof value)) {\n    throw new TypeError(`${name} value must be ${types.join(' or ')}, received \"${typeof value}\"`)\n  }\n}","typeGuard":"const isOfType = (value: unknown, types: string[]): boolean =>\n  types.includes(typeof value)","tryCatchPattern":null,"preventionTips":["Validate config values at the boundary before passing them into Vitest APIs.","Run pnpm typecheck in TS projects to catch type mismatches at compile time.","Document the expected typeof for each option in your config schema."],"tags":["utils","validation","type-mismatch","configuration"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}