fix(javascript): preserve semantic uncertainty and lexical ownership

This commit is contained in:
morluto committed 2026-10-14 09:47:29 +08:00
1 parent 9fe54c4073
commit 896696b2e7
16 files changed
+525 -20

No files matched your search

@@ -860,13 +860,18 @@ const hasConditionalInitializer = (ancestors: readonly t.Node[]): boolean => {
const node = ancestors[index];
if (t.isFunction(node) || t.isProgram(node) || t.isStaticBlock(node))
return false;
if (
t.isIfStatement(node) ||
t.isLoop(node) ||
t.isSwitchCase(node) ||
t.isTryStatement(node)
)
if (t.isIfStatement(node) || t.isSwitchCase(node) || t.isTryStatement(node))
return true;
if (t.isLoop(node)) {
const bodyOrTest = ancestors[index + 1];
if (
(t.isForStatement(node) && bodyOrTest === node.init) ||
(t.isDoWhileStatement(node) &&
(bodyOrTest === node.body || bodyOrTest === node.test))
)
continue;
return true;
}
}
return false;
};