fix(javascript): retain fresh function and class target identity

Recognize stable local function, undecorated class and RegExp targets before
widening intrinsic mutations. Keep decorated classes opaque because their
binding value can be replaced, and preserve class-initialization writes.
Cover fresh targets and replacement decorators in inert CLI/MCP fixtures.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: Kaoru0822 <[email protected]>
This commit is contained in:
committed 2026-10-11 15:41:00 +00:00
1 parent 5569e96162
commit b03df22ce4
4 files changed
+34 -5

No files matched your search

@@ -142,7 +142,13 @@ export const createSemanticModuleInterop = (
let current = node;
for (;;) {
current = unwrapJavaScriptExpression(current).node;
if (t.isObjectExpression(current) || t.isArrayExpression(current))
if (
t.isObjectExpression(current) ||
t.isArrayExpression(current) ||
t.isFunction(current) ||
(t.isClass(current) && !current.decorators?.length) ||
t.isRegExpLiteral(current)
)
return true;
if (!t.isIdentifier(current)) return false;
const binding = resolveSemanticBindingState(state, current, current.name);