{"record":{"id":"03d0bd96f83b23ad","repo":"vitest-dev/vitest","slug":"memberexpression-is-not-supported-please-open-a-n","errorCode":null,"errorMessage":"MemberExpression is not supported. Please open a new bug report.","messagePattern":"MemberExpression is not supported\\. Please open a new bug report\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mocker/src/node/automock.ts","lineNumber":123,"sourceCode":"            else {\n              property satisfies never\n            }\n          })\n        }\n        else if (expression.type === 'RestElement') {\n          traversePattern(expression.argument)\n        }\n        // const [name[1], name[2]] = []\n        // cannot be used in export\n        else if (expression.type === 'AssignmentPattern') {\n          throw new Error(\n            `AssignmentPattern is not supported. Please open a new bug report.`,\n          )\n        }\n        // const test = thing.func()\n        // cannot be used in export\n        else if (expression.type === 'MemberExpression') {\n          throw new Error(\n            `MemberExpression is not supported. Please open a new bug report.`,\n          )\n        }\n        else {\n          expression satisfies never\n        }\n      }\n\n      if (declaration) {\n        if (declaration.type === 'FunctionDeclaration') {\n          allSpecifiers.push({ name: declaration.id.name })\n        }\n        else if (declaration.type === 'VariableDeclaration') {\n          declaration.declarations.forEach((declaration) => {\n            traversePattern(declaration.id)\n          })\n        }\n        else if (declaration.type === 'ClassDeclaration') {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/mocker/src/node/automock.ts#L105-L141","documentation":"Thrown by `traversePattern` inside `automockModule` when a destructuring pattern in an `export const` declaration contains a `MemberExpression` — e.g., `export const { a: obj.prop } = x`, which assigns into a nested object property. The automock exporter cannot statically name such an export, so it refuses with a request to file a bug report.","triggerScenarios":"Automocking a module that uses a destructuring-pattern assignment target that is a member expression rather than a plain identifier or nested pattern.","commonSituations":"Rare in practice — most modules do not use member-expression assignment targets in `export const`. Encountered when automocking unusual or generated code that destructures into object properties.","solutions":["Provide an explicit factory: `vi.mock(path, factory)`.","Refactor the target module to avoid member-expression destructuring targets in exports.","File the bug report the message requests if you need automock to support this shape."],"exampleFix":"// before — automock cannot handle member-expression target\n// mod.ts: export const { a: cfg.value } = source\nvi.mock('./mod')\n// after — explicit factory\nvi.mock('./mod', () => ({ value: 1 }))","handlingStrategy":"fallback","validationCode":"// Member-expression destructuring targets are rare; scan for them and prefer explicit factories.\nfunction hasMemberExpressionDestructure(ast: any): boolean {\n  for (const node of ast.body) {\n    if (node.type !== 'ExportNamedDeclaration' || !node.declaration) continue\n    for (const decl of node.declaration.declarations || []) {\n      if (containsMemberExpression(decl.id)) return true\n    }\n  }\n  return false\n}","typeGuard":null,"tryCatchPattern":"try {\n  vi.mock('./mod')\n} catch (err) {\n  if (err instanceof Error && err.message.includes('MemberExpression is not supported')) {\n    vi.mock('./mod', () => ({ /* explicit stubs */ }))\n  }\n}","preventionTips":["Do not use member-expression assignment targets in export destructuring.","Provide an explicit factory for modules with unusual export shapes.","Refactor such exports to plain identifier assignments."],"tags":["automock","destructuring","member-expression","vi-mock"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}